Re: using multiple checkboxes to delete from db
| From: | Hugh Bothwell | Date: | Sun, 31 Mar 2002 01:31:15 +0000 |
| Subject: | Re: using multiple checkboxes to delete from db | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18065@lists.php.net to get a copy of this message | ||
You can go one better than this, even...
use PHP to construct a single SQL query
using the IN( ) comparator, ie:
<?php
// NOTE: this assumes that 0 is never a valid id; I just
// stuck it in to make the comma-delimiting come out right
$query = "DELETE FROM tablename WHERE id IN ( 0";
foreach($_POST["del"] as $val)
$query .= ', '.$val;
$query .= ' )';
[connect]
[query]
[close connection]
?>
"Olinux" <olnx@yahoo.com> wrote in message
news:20020330233817.14407.qmail@web11804.mail.yahoo.com...
> to make it a little better, make one connection to the
> db before you loop and then close the connection
>
> [connect]
> foreach loop
> [close connect]