I've been creating and using my own mySQL database management tools and have since began converting them for more specific administration pages for websites I maintain. I recently undertook the task of building a PHP-based mailing list/mailer administration page that works well except for one aspect.
On most of my admin pages, I have the option of selecting several checkboxes to delete several records from a table at once. These checkboxes' names are automatically populated to be the record's primary key. For my Email table, the Email address is the primary key, and so the check boxes, after the PHP is processed, look something like this:
<input type = "checkbox" name = "someemail@domain.com">
In this case, when the user submits the delete records form, variables are posted to the deletion PHP script that are named the same as the primary key of that record. The script, not wanting to delete any records that are not checked, then checks to make sure that the variable that is named the same as the primary key is checked, and, for this, I use the $_POST variable, like so:
while($row = mysql_fetch_row($result))
{
//Set key row to the first field's contents.
$keyrow = $row[0];
//If the checkbox corresponding to this row's primary key is checked. . .
if(isset($_POST[$keyrow]))
{
//Build delete query.
$delQuery = "delete from tblGigs where gigDate = '" . $row[0] . "'";
//Print delete query.
print("$delQuery<br>");
//Run query.
mysql_query($delQuery)
OR die(mysql_error());
}
}
This method has worked really well so far with all of my other tables, but, when the key is an Email address, the isset function returns false, and so nothing is deleted. Does anyone have any ideas on how this might be resolved?