RE: [phplib] OT: Deleting Queries from Checkbox From: Layne Weathers (layne <email protected>)
Date: 05/16/01

> I have query that lists all the rows in a table. I would like
> to be able to delete any of them using a checkbox. I added
> the checkbox tags in a while loop along with the rest of the
> queries so it prints out nicely. Of course I have a statement like:

In the HTML, I will have something like:

        <input type=checkbox name=test_1 value=delete> Name of 1
        <input type=checkbox name=test_2 value=delete> Name of 2
        ...

 
> mysql_query("DELETE FROM test_table WHERE ????")
>
> This is the part I am stuck at...How exactly do I write this
> part of the code not knowing how many checkboxes will be
> selected to delete?

In my form action script:

foreach($HTTP_POST_VARS as $key => $value) {
        if(($value == 'delete') and ereg('test_([0-9]+)', $key, $reg)) {
                mysql_query("delete from test_table where id = '$reg[1]'");
        }
}

Layne Weathers
Ifworld, Inc.

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>