Jump to content

Deleting multiple posts

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Carlo717

Carlo717

    Newbie

  • Members
  • Pip
  • 9 posts
I'm creating an admin system for my wall now and want to be able to delete multiple posts at once rather than just go back and forth deleting them one by one.

My idea was to use checkboxes to do this. I have a form and then my while loop getting all the posts and in this i have included a checkbox with each post where the value of the box is the id of the post ... and then the submit button after the loop.

At the top of the page I check to see if it's been submitted and then I want to delete all the posts where the ip = the ip of a checked checkbox ... how could I do this?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
easiest is to create an array of IDs. with
<input type="checkbox" name="id[]" value="56" />
<input type="checkbox" name="id[]" value="57" />
<input type="checkbox" name="id[]" value="58" />
you get a array in return on $_POST['id'], and can therefore delete all with a simple foreach-loop, or build a single statement with
DELETE * FROM table WHERE id IN (56, 57, 58);
etc
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall