I have this code,
$q = $dbc -> prepare ("SELECT * FROM tasks ORDER BY date_time LIMIT 0, 15");
$q -> execute();
echo '<form action="/adminpanel?tab=process" method="post">
<input type="hidden" name="deletetask" />';
while ($todo = $q -> fetch(PDO::FETCH_ASSOC)) {
echo '<div id="update"><div><strong>'
. $todo['date_time'] . '</strong><span>' . $todo['type']
. '</span></div><p>' . $todo['message']
. '</p><input class="checkbox" name="deletetask" value="'
. $todo['date_time'] . '" type="checkbox" /></div>';
}
echo '<input type="submit" value="Delete Tasks" /></form>';
Now everything works as expected apart from one thing and I haven't really found any answers on the internet. My while loop will have always more than one row, and will almost always want more than one deleting from it to.
As this script stands the form does work but it will only delete the last checkbox that was clicked. I understand why it is doing this, but I don't understand how to overcome this problem I am using PDO and prepared statements.