I have a form that includes a delete button. I want the user to be able to select all the items they wish to delete at once. I managed to get the echo to display but the items still remain on the page. Can you please point out why that happens? Any help is appreciated!
Delete button:
<input name="del_btn" type="submit" value="Delete">
The check:
if (isset($_POST['del_btn']) && $_POST['del_btn']){
for($i = 0; $i < count($_POST['checkbox']); $i++){
if (isset($_POST['checkbox'])) {
mysql_query("DELETE FROM `posts` WHERE `id` = '" . $_POST['checkbox'][$i] . "' LIMIT 1");
echo 'deleted';
}
}
}
the items' checkbox:
<input name="checkbox[]" type="checkbox" id="<?php echo $id; ?>" />
if (isset($_POST['checkbox']))when you have already used that variable in a reading context the line before does not make any sense.