Ive used the following code to delete and array of checkboxes from another page written in php but I can only delete 1 entry at a time
<?php
$checked = "";
$status = (isset($_REQUEST['status'])); //Checks if any checkboxes have been selected
if ($status == 'checked') {
$status = 1;
$checked = 'checked="checked"';
$value = $_POST['status']; //Uses the value of the checkbox
foreach ($value as $val) { //Loops through all of the checkboxes that have been selected
$sql = "DELETE FROM users WHERE ID='$val'"; //Mysql code to delete from the databases where items have been selected
if ($conn->query($sql) === TRUE) { //If a value has been deleted
echo "Record deleted successfully: ";
} else {
echo "Error deleting record: " . $conn->error; //Prints error if value hasnt deleted
}
$conn->close();//Closes sql connection
echo $val; //Echos values selected
echo '</br>';
}
} else {
$status = 0;
}
echo <<<END
END;
?>