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?
Deleting multiple posts
Started by Carlo717, Nov 07 2010 08:48 AM
1 reply to this topic
#1
Posted 07 November 2010 - 08:48 AM
|
|
|
#2
Posted 07 November 2010 - 01:32 PM
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
I study Information Systems at Karlstad University when I'm not on CodeCall


Sign In
Create Account

Back to top









