Jump to content


Photo

Mysql Deleting A Bulk


  • Please log in to reply
1 reply to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 29 June 2006 - 05:19 PM

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?

#2 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 29 June 2006 - 05:30 PM

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)";
Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users