Delete Multiple Records From Checkboxes
| From: | Albert Padley | Date: | Thu, 27 May 2004 01:34:03 +0000 |
| Subject: | Delete Multiple Records From Checkboxes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-187026@lists.php.net to get a copy of this message | ||
I've checked the archives and several other sources, but still can't seem to make this work.
I have a form with checkboxes to designate records to be deleted from the mysql database. The pertinent form code is:
<input type=\"checkbox\" name=\"del[]\" value=\"" . $row['id'] . "\">
The processing code is:
if (count($del) > 0){
for ($i=0;$i<count($del);$i++){
$query = "DELETE FROM ref_events_reg WHERE id = '$del[$i]'";
}
}
Echoing the query produces:
DELETE FROM ref_events_reg WHERE id = A
I've also tried the following:
$query = "DELETE FROM ref_events_reg WHERE id IN ('" . implode("','", addslashes($del)) . "')";
This one produces a warning:
Warning: implode(): Bad arguments.
and the following query:
DELETE FROM ref_events_reg WHERE id IN ('')
Both attempts fail to delete any records even though several records are checked.
Where have I gone wrong?
Thanks.
Albert Padley