Jump to content

Mysql Deleting A Bulk


xyn

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?
Link to comment
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)";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.