Posted: Sat Aug 12, 2006 11:31 am
ENT_QUOTESscottayy wrote:Code: Select all
$to_be_deleted[] = mysql_real_escape_string($delgig,ENT_QUOTES);
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
ENT_QUOTESscottayy wrote:Code: Select all
$to_be_deleted[] = mysql_real_escape_string($delgig,ENT_QUOTES);
Code: Select all
$delerror = false;
if (isset($_POST['del'])) {
if(!empty($_POST['check'])){
foreach ($_POST['check'] as $delgig) {
mysql_query("DELETE FROM gigdates WHERE pkey = '" . mysql_real_escape_string($delgig) . "'");
}
}else{
$delerror = true;
}
}Code: Select all
<?php
/* If no checkboxes ticked do error message */
if ($delerror) = true{
echo 'Select atleast one checkbox if you want to delete a gig';
}
?>Code: Select all
mysql_query("DELETE FROM gigdates WHERE pkey = '". (int) $delgig . "'");On admin screens I tend to do that on the client, using JS, using a confirm / then form.submit.santosj wrote:For usability, why would you tell someone that they didn't check any boxes? I believe it would be quite obvious once they find that the row still existed. It also takes a conscious action to check a box, even with tab key and space. I believe a better action would be to confirm that they really want to delete the rows they selected.
If they didnt select an item the form wouldnt be allowed to submit anyway.richo wrote:The reason i'm doing this is because if it didn't have it in, if they pressed submit it would come up with a php error instead which would be quite bad for a user to see.