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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to