I believe what you want to do is create an array with the id and delete as
separate values.

Here's an example using an array of studentdata containing variables
send_mail, this_studentname, this_paid.

The rows of students are output like this:

         <input type='checkbox'
name='studentdata[$this_student_id][send_mail]' value='Yes' checked>
         <input type='hidden'
         <input type='hidden'
name='studentdata[$this_student_id][this_paid]' value='$this_paid'>

In this case all of the checkboxes are "checked."

When the form is submitted, those students who have the checkbox checked
have the variable send_mail set to Yes.

When I want to process the array it looks like this:

foreach($studentdata as $student_id => $data)
  $dues_paid = $data[this_paid];
  $studentname = $data[this_studentname];
  $send_mail = $data[send_mail];
   if ($send_mail == "Yes")

     # Your sql statement and processing goes here

   }# end if
}# end for each

Hope this helps.

John Hughes

----- Original Message -----
From: "wesley grubbs:." <[EMAIL PROTECTED]>
Sent: Saturday, March 30, 2002 4:58 AM
Subject: [PHP-DB] using multiple checkboxes to delete from db

> i've been playing half the day with trying to get php to delete rows when
> checkbox is checked.
> i have a page that pulls all the data from db in a table. one row contains
> checkboxes. i want it so that whereever a checkbox is checked and then
> submit, all the selected rows will be deleted.
> <table>
> <?php
> //get results from db
> while($row = mysql_fetch_array ($result)) {
> ?>
> <tr>
> <td><input type="checkbox" name="delete" value="<?php print($row[id]);
> ?>"></td>
> </tr>
> <?php
> }
> ?>
> </table>
> what's the proper function i should write for this?
> also, can i put the function on the same page without useing SWITCH?
> i'm trying to minimize the number of files i have.
> thanks in advance for any help.
> wes
> www.devedeset.com
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

Reply via email to