|
Posted by blackwater dev on 11/30/05 05:15
I have a form where I am dynamically building a bunch of checkbox
inputs. Then when submitted, I need to update the db. Problem is, of
course, if the checkbox is unchecked then the $_POST doesn't have the
value in the array. How can I get the value from $_POST even though
it's unchecked?
For example, here would be the generated form:
<input type="checkbox" name="cars[2]" value="1">Car 1
<input type="checkbox" name="cars[3]" value="1">Car 2
<input type="checkbox" name="cars[4]" value="1">Car 3
<input type="checkbox" name="cars[5]" value="1">Car 4
Then in the update I loop through:
foreach($_POST[cars] as $id=>$value){
//update vehicles set value to yes or no
}
But, if the unchecked values aren't in $_POST, how do I know to update them???
Thanks!
[Back to original message]
|