checkboxes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux