Hi, Thursday, May 27, 2004, 3:07:28 PM, you wrote:
AP> On May 26, 2004, at 7:55 PM, Tom Rogers wrote: >> Hi, >> >> Thursday, May 27, 2004, 11:34:03 AM, you wrote: >> AP> I've checked the archives and several other sources, but still >> can't >> AP> seem to make this work. >> >> AP> I have a form with checkboxes to designate records to be deleted >> from >> AP> the mysql database. The pertinent form code is: >> >> AP> <input type=\"checkbox\" name=\"del[]\" value=\"" . $row['id'] . >> "\"> >> >> AP> The processing code is: >> >> if (count($del) >> 0){ >> AP> for ($i=0;$i<count($del);$i++){ >> >> AP> $query = "DELETE FROM ref_events_reg WHERE id = '$del[$i]'"; >> AP> } >> AP> } >> >> AP> Echoing the query produces: >> >> AP> DELETE FROM ref_events_reg WHERE id = A >> >> AP> I've also tried the following: >> >> AP> $query = "DELETE FROM ref_events_reg WHERE id IN ('" . >> implode("','", >> AP> addslashes($del)) . "')"; >> >> AP> This one produces a warning: >> >> AP> Warning: implode(): Bad arguments. >> >> AP> and the following query: >> >> AP> DELETE FROM ref_events_reg WHERE id IN ('') >> >> AP> Both attempts fail to delete any records even though several >> records >> AP> are checked. >> >> AP> Where have I gone wrong? >> >> AP> Thanks. >> >> AP> Albert Padley >> >> >> change it to >> >> <input type=\"checkbox\" name=\"del[$row['id']]\" value=\"Y"\"> >> >> Then you can do something like >> >> foreach($del as $id=>$val){ >> $query = "DELETE FROM ref_events_reg WHERE id = '$id'"; >> //do query >> } >> >> -- >> regards, >> Tom >> AP> Tom, AP> When I tried this I received a warning - Warning: Invalid argument AP> supplied for foreach() AP> and, of course, no records were deleted. AP> Albert Padley you would need to add a bit of code, that was very rough, I assumed you got $del from $_POST if(isset($_POST) && is_array($_POST['del'])){ foreach($_POST['del'] as $id=>$val){ . . . } } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php