I have an array of checkbox in a table in PHP file like this :
echo "<td $Blocked><input type =\"checkbox\" name=\"Blocked[]\" value=\"checkblock\" /></td>";
I am trying to get the value of number of checked checkboxes and save it to DB.
$Blocked = 'unchecked';
if ((isset($_POST['edit_tc']))) {
if (isset($_POST['Blocked'])) {
if (is_array($_POST['Blocked'])) {
foreach($_POST['Blocked'] as $value) {
error_log($value);
}
}
else {
$value = $_POST['Blocked'];
error_log($value);
}
$Blocked = 'checked';
}
}
"edit_tc" is the Submit button.
How do I take the number of it when the user checks the checkbox & clicks Submit button to save it to a table column?