chinclub Posted July 3, 2007 Share Posted July 3, 2007 I know how to delete, insert, and update an item in the database using PHP. Is there a way to do multiple items as once? For example. I have written in simple messaging system for my members. Right now there is a link beside each message to delete it from the database. And I use this simple code to do it: $del = mysql_query("DELETE FROM `messages` WHERE `id`='$id'"); I would love to have a check box beside each one and then a delete button at the bottom so you can delete multiple messages at once. I am good with writing the HTML for that but how would the PHP code look that would delete each of the messages they have chosen? I have tried finding a tutorial for this on the web but no luck yet. Quote Link to comment Share on other sites More sharing options...
pikemsu28 Posted July 3, 2007 Share Posted July 3, 2007 <?php $del = $_POST['del']; $num = count($del); for($i = 0; $i < $num; $i++){ $ID = $del[$i]; $sql = "DELETE FROM `messages` WHERE `id`='$id'"; $results = mysql_query($sql) or die("ERROR"); ?> that is what i use Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.