Jump to content

Archived

This topic is now archived and is closed to further replies.

xyn

Mysql Deleting A Bulk

Recommended Posts

Hi.

I was wonering how to delete several items from a MYSQL Database using Check Box's. Say i had 1- messages. ID: 1,2,3,4,5,6,7,8,9 and 10. I wanted to delete id: 1,5,7. by ticking the box..

How would I make this possible?

Share this post


Link to post
Share on other sites
make a list of check box with same name like this:
<input type="checkbox" name="delete[]" value="$id">
each check box has different value id.

then after POST, if user check box 3,5,7, the $_POST['delete'] will be an array of value like this:
$_POST['delete'][0] = 3;
$_POST['delete'][1] = 5;
$_POST['delete'][2] = 7;

then simply retrieve these 3,5,7 and set up a query.
something like this:

"delete from table where id in (3,5,7)";

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.