How to delete multiple data entries using checkboxes in PHP?

Home / Uncategorized / How to delete multiple data entries using checkboxes in PHP?

Ok I know this question has been asked before and we have run through a lot of different answers… However we still can’t get this working right.

This is higher up in the code where the threads are displayed. It is also nested inside of an echo that is displaying the table. Except for the that is marked by comments, all the others are not next to code like they are shown. I wanted the code to highlight the right way.

$c = $c==1?2:1;

echo ‘

id).’" />

//More displaying table code here.

}$s->close(); ?>

Lower down in the code near where the buttons appear at the end of the page we have this.

$query=("delete from forumthreads where ‘id’='{$del_id->id}’");

} //for
} //ispost delete
} //isstaff ?>

The goal of this code to is grab the Thread id number from the checkboxes and run it through a deletion function when a button is pressed. Giving staff members the power to delete multi threads in a board at once.

This code works only to delete a single thread and is what we are basing the multi delete thread function on. It is in a different file "thread.php"
query("DELETE FROM forumposts
WHERE `thread`='{$thread->id}’");

if ($db->error) die(trigger_error($db->error) );

$db->query("DELETE FROM forumthreads
WHERE `id`='{$thread->id}’");

if ($db->error) die(trigger_error($db->error) );


echo ‘

id).’" />

In PHP File:$ids = implode(‘,’, $_POST[‘check’]);
mysqli_query("delete from forumposts where id in ($ids)");
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *