I'm trying to delete multiple records in a database based on selections from check boxes in a form. But if multiple check boxes are selected, the current sql only deletes first id for some reason, and not deleting the rest.
$del_ids = implode(',', array_keys($_POST['check_list']));
$query = "DELETE FROM enhancements WHERE id IN('$del_ids')";
$result = mysqli_query($connection, $query);
For example my array looks like this:
Array
(
[check_list] => Array
(
[4] => on
[6] => on
)
)
And after running:
$del_ids = implode(',', array_keys($_POST['check_list']));
my $del_ids string looks like this:
4,6
But for some reason only record with id 4 deletes, and record with id 6 does not delete and they should both delete. Any suggestions?
IN ('4,6')WHERE id IN('".$del_ids."')toWHERE id IN(".$del_ids.")