Hello, just wondered if anyone could help please? I am new to php and I am trying to update by database so that if any check boxes are checked then update to 'yes' and any check boxes that were not checked to be updated to 'no'. My code for creating the check boxes is:
print "<td align = \"CENTER\" bgcolor=\"$color\">" . "<input type=\"checkbox\" name=\"fchk1[]\" value=\"$doc_no\" echo '$checked' >
and my code for the action page is:
if(isset($_POST['update'])) {
$fchk1=$_POST['fchk1'];
if (is_array($fchk1)){
foreach ($fchk1 as $doc_no){
$update_query = "UPDATE uploads u SET u.saccess = 'yes' WHERE u.doc_no = '$doc_no'";
$result = $db->query($update_query);
//$db->disconnect();
header("Location: main.php?target=docs&type=h");
}
}
else {
$update_query = "UPDATE uploads SET saccess = 'no'";
$result = $db->query($update_query);
//$db->disconnect();
header("Location: main.php?target=docs&type=h");
}
}
the checked part works fine, but the unchecked part does not work unless there is no checked boxes. Is what i am trying to do even possible? any help would be really appreciated.
Thank you Emma