Hi,
I have a number of rows with checkboxes:
echo '<tr><td class="text">'.$rowProduct['product'].'</td><td class="text"><input name="price[]" type="text" value="'.$rowProduct['price'].'" class="text"><input name="id[]" type="hidden" value="'.$rowProduct['ID'].'"></td><td width=50><input name="available[]" type="checkbox" value="1"></td></tr>';
if I check some of checkboxes and click submit, data should be submitted to DB:
if ($HTTP_POST_VARS){
for ($i =0; $i<count($price); $i++) {
if (!isset($available[$i])) $available[$i] = 0; //if empty
$connector->query('UPDATE test SET price="'.$price[$i].'",available='.$available[$i].' WHERE ID='.$id[$i]);
}
}
Text values (prices) are submitted correctly, however, checkboxes aren't. If I check 2 random checkboxes they are written in DB as the first 2. On the other hand, If I uncheck any 3-4 checkboxes and leave others checked, only the last 3-4 checkboxes are set to 0 in DB.
I've tried to check before submission if a checkbox is empty:
if (!isset($available[$i])) $available[$i] = 0; //if empty
but it doesn't work.
Any idea?
witold