One way you could do this.  Is have the form point to itself i.e. $PHP_SELF,
then set a variable in the form if it is set when the page loads the run the
form processing script.  As for the delete function one way to do it would
be since you are holding the checkboxes in an array.  Do a while or a for
loop doing the delete statement for each id.  Like the following code.

for($i = 0; $i < count(chkBoxArray); $i++){
      $sql = "DELETE FROM tblName WHERE tblID =  '$row[$i]'";
            echo "ERROR: ".mysql_query();

Or something of that sort.  Hope it helps.


----- 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
> --
> PHP Database Mailing List (
> To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to