I am trying to use checkboxes from column items in my database table, then take the selections for use in my query. My problem is that the only passed variable is the last item in the series that has been chosen. How do you pass multiple selected values for the same "name" value (in separate checkboxed input fields) to the form handler (and how do you deal with them to separate them out??
the following snippets approximate what I have so far:
****From Form Input - these are generated dynamically from a MySQL table ****
<nobr><input type=checkbox name="state" value="CO">Colorado</nobr><br>
<nobr><input type=checkbox name="state" value="CT">Connecticut</nobr><br>
<nobr><input type=checkbox name="state" value="DC">District of Colombia</nobr><br>
****
****In Form handler****
$_POST['state'];
if (!is_array($state)) {
// action if not an array -- this is not the actual action I would use
echo "$state";
} else {
while(list($key2,$val2) = each($state)) {
// action if it is an array -- same deal -- would actually use values in a query
echo "$val2[$key2]";
}
}
****
$state appears to ONLY be a variable (not an array), even when more than one checkbox is chosen. I know that with the 'multiple' option in <Select> inputs that you need to place brackets [] after the name to have the multiple items passed through as an array, but what do I do to get an array from multiple checkboxes?? Or is there an alternative?
Thanks