Let me get this straight...
You have X amount of rows outputted to the screen, each with its own checkbox appended to it. When a checkbox is checked and submitted you want all corresponding checked rows to be deleted? If that is the case then you can use what I use:
Your outputted rows should look something like that following:
Code:
<input type="checkbox" name="chbox[]" value="$Id" id="chbox[]" />
<input type="checkbox" name="chbox[]" value="$Id" id="chbox[]" />
<input type="checkbox" name="chbox[]" value="$Id" id="chbox[]" /> etc..
$Id is the unique value of the checkbox, obtained from the rows unique ID in the database. I'm not sure if you need the id="" section - its been a while since I have had to fiddle with PHP. I have left it there in case you do.
Then to delete the actual rows use this:
Code:
if(isset($_POST['submitDeleteButton']))
{
foreach($_POST['chbox'] as $key =>$val)
{
mysql_query("DELETE FROM table_name WHERE id='$val'");
}
}
Its operation is simple: foreach name="chbox" submitted assign it an array id and store the id in $key then correspond each id held in $key with the value="" part of the checkbox and stick that value into $val. Thats more or less how it works, at least that how I understand it to work; I'm not saying I'm right however
. if you change chbox in the foreach statement, make sure you change the name="" section of the input control. You can also change $val to whatever you like, but I believe $key has to stay as $key.
PS - Don't forget to sanitize any user data going in/out of the database when using something like $_POST or $_GET.