Reply to checkboxes

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация