The form has a <select> of four <option>
<select name=group size=1 onchange=""> <option name="pay_op" value="Приближение срока оплаты">Приближение срока оплаты</option> <option name="orders_op" value="Технические работы">Технические работы</option> <option name="news_op" value="Новости компании">Новости компании</option> <option name="other_op" value="Прочая информация">Прочая информация</option> </select>
value from it is written to the field of the table, the structure of which is this:

In the field index2 wrote down numbers manually.
And you need to make sure that when you select a group in <select> , not only value automatically sent to the database, but also the corresponding index2 .
That is, in the form I choose “Approximation of payment deadline” and at the same time “1” is written in the field index2 , I choose “Technical works” - it is recorded “2”, etc.
Can you hang on each option id-shnik, and implement it using onchange ? But so far I have no idea how.
UPDATE:


Selection from tables:
$result = database_select("SELECT g.name AS group, m.title AS title, m.message AS message FROM `vixen_erps_messages_sms` m INNER JOIN `vixen_erps_messages_group` g ON g.group_id = m.index2");