Run into a bit of a roadblock and hoping someone here could help me out. Here's my code:
function viewGuestbook($isadmin)
{
GLOBAL $sitename,$tablebordercolor,$tdbgcolor,$smallfont,$smallfontcolor,$smallfontface,$smallfontsize,$cs;
$result = mysql_query("SELECT * FROM arc_guestbook ORDER BY guestid");
if ($isadmin=='yes') echo '<form action="admin.php?action=deletegb" method="post">';
while ($row = mysql_fetch_array($result)) {
if ($isadmin=='yes') {
$deleter = " <input type=\"checkbox\" name=\"guestid\" value=\"$row[guestid]\" />Delete?";
} else {
$deleter = '';
}
echo "
<table bgcolor=\"$tablebordercolor\" cellpadding=\"0\" cellspacing=\"0\" width=\"400\"><tr><td>
<table width=\"100%\" border=\"0\" cellspacing=\"1\">
<tr>
<td bgcolor=\"$tdbgcolor\" width=\"100\">$smallfont Name: $cs</td>
<td bgcolor=\"$tdbgcolor\">$smallfont<strong>$row[guestname]</strong> $deleter$cs</td>
</tr>
<tr>
<td bgcolor=\"$tdbgcolor\">$smallfont Email Address: $cs</td>
<td bgcolor=\"$tdbgcolor\">$smallfont<a href=\"mail.php?addr=$row[guestmail]\" title=\"Click here to send $row[guestname] an email.\">$row[guestmail]</a>$cs</td>
</tr>
<tr>
<td bgcolor=\"$tdbgcolor\">$smallfont Website URL: $cs</td>
<td bgcolor=\"$tdbgcolor\">$smallfont<a href=\"$row[guestsite]\" target=\"_blank\">$row[guestsite]</a>$cs</td>
</tr>
<tr>
<td bgcolor=\"$tdbgcolor\" colspan=\"2\">$smallfont$row[guestcomment]$cs</td>
</tr>
</table></td></tr></table><br />";
}
if ($isadmin=='yes') echo '<center><input type="submit" value="Submit" /></form>';
}
This function takes one argument so I call it from the cp with $isadmin set to 'yes' and from the unrestricted areas set to 'no' and it builds checkboxes named according to the databases id column name and value so I can check the boxes I want to delete (from the guestbook although I would apply the principal to other areas of my project). The problem is, as it is now it only deletes the last selected object. I want to make it delete all selected rows with the checkboxes checked when it recieves POST variables by the elements id.
Here's the code I use right now to delete the selected row:
doQuery("DELETE FROM guestbook WHERE guestid='$guestid'");
I've already extract()'ed the HTTP_POST_VARS in my script so this has everything it needs to delete that one file. If worse comes to worse I could always change the inputs to radio buttons and fake it....