Hi
I have an array of checkboxes whose values if checked can be updated in mysql. The code I have below accomplishes that just fine.
On my form I have:
PHP Code:
print "<form method='post' action='update.php'>\n";
/////// mysQL query here
$myID = $itemRow['myID'];
$chk = $itemRow['item_shipped'] == 1 ? 'checked' : '';
echo "<input type=checkbox name=cbox[] value='{$itemRow['myID']}' $chk>";
echo"</form>";
The above code displays various items with a checkbox next to them. So if that checkbox is checked the code below stores that in mysql.
On my update.php page I have:
PHP Code:
if(sizeof($_POST['cbox'])) {
//means if at least one check box is selected
foreach($_POST['cbox'] AS $id) {
mysql_query("UPDATE om SET item_shipped ='1' WHERE myID=$id");
} //end foreach
} //end IF
The problem is though i can check a checkbox and store that value '1' in mysql, I have no way of unchecking an already checked checkbox and storing the '0' in mysql.
Can anyone help?
Thanks in advance