I have an array of checkboxes that I edit at once to set up a 'tinyint' field. the problem comes in when i uncheck the checkbox and post the vales to mysql. since it posts an array of checkboxes and another parallel array of values to edit, unchecking a checkbox results in the 0
value been ignored by PHP_POST and hence the checkbox array will be less by the number of unchecked values in the form while the array to be edited will have all the records in the form.
here is the submit code
while($row=mysql_fetch_array($result))
{
$checked = ($row[active]==1) ? 'checked="checked"' : '';
...
echo "<input type='hidden' name='TrID[]' value='$TrID'>";
echo "<input type='checkbox' name='active1[]' value='$row[active]''$checked' >";
...
and the processing php script
$userid = ($_POST['TrID']);
$checked= ($_POST['active']);
$i=0;
foreach ($userid as $usid)
{
if ($checked[$i]==1){
$check = 1;
}
else{
$check = 0;
}
$qry1 ="UPDATE `epapers`.`clientelle` SET `active` = '$check' WHERE `clientelle`.`user_id` = '$usid' ";
$result = mysql_query($qry1);
$i++;
}