If you had a blogging engine that you custom wrote, and you wanted to be able to delete multiple entries via a HTML form with check boxes rather than deleting one entry at a time, how would you do this with PHP and SQL?
Where entries will be your array and the numbers are entry ids. When this is submitted, you will be able to access the array via $_POST['entries]. Any checked checkboxes will be in the array, any unchecked ones wont.
How would I do this while fetching the other table fields and displaying them in the form at the same time? I was going to display information about the posts on the delete page, to make it easier to know what you're deleting. However, looking at this, I don't know how to accomplish both at the same time without messing something up.
I'm not sure I follow. Could you not just query the database for the post information you wish to show on the delete page, and build your form using checkbox arrays?
ie:
PHP Code:
// get the post data here echo '<form method="post" action="foo.php">'; while ($row = mysql_fetch_assoc($result)) { echo 'Delete? <input type="checkbox" name="entries[' . $row['id'] . ']" />' echo '<div>' . $row['title'] . '</div>'; echo '<div>' . $row['content'] . '</div>'; } echo '</form>';
Bookmarks