Forum Moderators: coopster

Message Too Old, No Replies

Code for multiple posts delete.

         

bestempire

5:19 am on Jul 18, 2009 (gmt 0)

10+ Year Member



I am looking for some coding which can help me to delete multiple posts by ticking/choosing boxes. All I would like to do is to choose the posts first (by ticking) then choose Delete chosen Posts after wards. I need to implement this one my classified ads website which has many spam posts and need to be deleted

Currently I have to delete one by one which is very time consuming

Thanks for any idea or sample code.

Bestempire

dreamcatcher

6:15 am on Jul 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi bestempire, welcome to Webmaster World. :)

I assume each entry has an id number? If so, try the following:

Set up your checkboxes:

<input type="checkbox" name="id[]" value="classified id here.." />
<input type="checkbox" name="id[]" value="classified id here.." />
<input type="checkbox" name="id[]" value="classified id here.." />

On process, delete any that are checked:


if (!empty($_POST['id'])) {
mysql_query("DELETE FROM classifieds WHERE id IN (".implode(',',$_POST['id']).")") or die(mysql_error());
}

Hope that helps.

dc