Re: deleting multiple items from a database
| From: | Robby Russell | Date: | Wed, 13 Oct 2004 20:58:55 +0000 |
| Subject: | Re: deleting multiple items from a database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199438@lists.php.net to get a copy of this message | ||
On Wed, 2004-10-13 at 16:11 -0400, Adil wrote:
> function deleteFiles() {
> foreach($_POST['stack'] as $i) { //This should work but I
> can't
> tell if it is or isn't
> mysql_query("DELETE FROM uploads WHERE upload_id =" . "$i");
> }
> header("Location: http://" .
> $_SERVER['PHP_SELF']); //forces
> a
> page refresh to show the file list without the items that were
> deleted.
> }
For sanity of your mysql database, you might consider making this one
query.
Something like
DELETE FROM table WHERE id IN (32,34,46,432,35);
generating your list of numbers/ids from your array...
-Robby
--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc