I am trying to handle duplicate variables from a form, and enter the value for each duplicate variable on a new line in a table. I am sure the method I have come up so far with is not the best, so any other ideas would be greatly appreciated.
First, I have a form which has a section that is dynamically generated:
<?php do { ?>
<tr>
<th><?php echo $row_ModeList['ModeName']; ?>:</th>
<td><input type="checkbox" name="DevMode" value="<?php echo $row_ModeList['ModeID']; ?>"></td>
</tr>
<?php } while ($row_ModeList = mysql_fetch_assoc($ModeList)); ?>
When the form gets submitted, via POST method, there is a DeviceID variable I am passing as an identifier and there are multiple DevMode=x variables that are passed as well. What I need is to be able to is enter into a table a row for every instance of DevMode two values; DeviceID and the value of DevMode.
So if the values from the form passed are: ?DeviceID=29&DevMode=1&DevMode=2&DevMode=3 then I need three rows entered in a table:
DeviceID | DevMode
29 | 1
29 | 2
29 | 3
Apparently on the form side there is a way to get all instances of DevMode to go into an array by name="DevMode[]", but I cannot figure out how to handle the data on the other side. When I print the array to see what I got, it comes up as "array ([0] => 1, [2] => 2, [3] => 3);". As you can see, the keys are numeric, not DevMode as I would have expected. I looked into replacing the key(s) to something else, but that was unsuccessful.
Any help would be greatly appreciated. Thanks.