PDA

View Full Version : checkboxes and mysql


harmor19
10-23-2005, 09:40 PM
I have been searching but I don't understabd how exactly I would do it.

I am putting the checboxes in a while loop so it appears beside each entry.
How do I go about deleting the entries where checkbox is ticked?

Here's the checkbox field,
<input type="checkbox" name="tests[]" value="$testimnonial[id]" />

I found a good tutorial on checkboxes and php.
I had to edit a little but I got it.


$tests = $_POST['testimonials'];
$n = count($tests);
$i = 0;

while ($i < $n)
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "testimonials WHERE testid='$tests[$i]' ");
$i++;
}