Unfortunately when a form is submitted with checkboxes (or
radio
buttons) unchecked, those variables are not sent (or at
least
interpreted by PHP) to the server. You get either
"on" or nothing.
I'm guessing it's because "off" is basically null,
and if a variable is
null then it's really not set anymore.
Anyway, a way to get around that would be to have a
pre-determined
number of checkboxes either in a hidden variable or on the
server's
action page. So if you have 10 checkboxes numbered
checkbox[1],
checkbox[2], etc, and then a hidden variable named
"checkbox_count" and
set to 10, you could say:
<?php
for($i = 1; $i <= count($_POST['checkbox_count']);
$i++)
{
if(isset($_POST['checkbox[$i]']))
{
// insert 1 into database
}
else
{
// insert 0 into database
}
?>
--~--~---------~--~----~------------~-------~--~----~
This group is managed and maintained by the development
staff at 360 PSG. An enterprise application development
company utilizing open-source technologies for todays
small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the
Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professional-PHP googlegroups.com
To unsubscribe from this group, send email to
Professional-PHP-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/Professional-PHP
-~----------~----~----~----~------~----~------~--~---
|