Im in need of some assitance in order to implement a multiselect selection box and then inserting the choices as seperate records into a table in a MySql DB.
For the form, Im pulling information from two tables, then inserting it into a third as seperate records, based on what is chosen in the multiselect box.
From table 1 , Im pulling the last record inserted.
From table 2 , Im pulling in the memberid and membername (multiselect box)
For table 3, should insert whatever is selected in the multiselect box as seperate records from table 1.
Ie, if last record was #45
Multiselect box chosen were id's 3,4,6,9 (shown name of member, but only their id will be inserted into the table)
Table 3 would result in :
45 | 3
45 | 4
45 | 6
45 | 9
My multiselect box code looks like this:
How can I construct the MySQL insert query so that it loops through the chosen selections and inserts them until all are inserted?
For the form, Im pulling information from two tables, then inserting it into a third as seperate records, based on what is chosen in the multiselect box.
From table 1 , Im pulling the last record inserted.
From table 2 , Im pulling in the memberid and membername (multiselect box)
For table 3, should insert whatever is selected in the multiselect box as seperate records from table 1.
Ie, if last record was #45
Multiselect box chosen were id's 3,4,6,9 (shown name of member, but only their id will be inserted into the table)
Table 3 would result in :
45 | 3
45 | 4
45 | 6
45 | 9
My multiselect box code looks like this:
Code:
<select size=10 multiple name="who">
<?php
$q="select member_id, membername from members
order by member_id asc";
$r=mysql_query($q) or die(mysql_error().$q);
while($row=mysql_fetch_array($r)) {
echo "<option value=\"".$row["member_id"]."\">".$row["membername"]."</option>";
}
?>
</select>
How can I construct the MySQL insert query so that it loops through the chosen selections and inserts them until all are inserted?