WG: [PHP-WIN] Re: [PHP] Deleting multiple items from database using checkboxes
| From: | Philipp Lutz | Date: | Tue, 08 Oct 2002 12:42:58 +0000 |
| Subject: | WG: [PHP-WIN] Re: [PHP] Deleting multiple items from database using checkboxes | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-16247@lists.php.net to get a copy of this message | ||
How about :
if (is_array($dele))
{
$sql= "DELETE FROM gastenboek WHERE entryID IN (".join(",",$dele).");
mysql_query($sql, $connection);
};
Quicker and Cleaner ... and MySQL has less to check...
philipp.lutz@zellwerk.com
tech expert
pinienstrasse 2
40233 duesseldorf
<tel> 0211 4 95 35 49
<fax> 0211 5 07 22 13
> -----Ursprüngliche Nachricht-----
> Von: Ing. Raúl González Rodríguez [mailto:raul@mtz.jovenclub.cu]
> Gesendet: Montag, 7. Oktober 2002 22:48
> An: Php Mailinglist; Php-Windows Mailing
> Betreff: [PHP-WIN] Re: [PHP] Deleting multiple items from database
using
> checkboxes
>
> You can use the following code to delete multiple items:
>
> if(isset($dele) && (count($dele) > 0)) {
> $sql = "delete from gastenboek where (entryID='$dele[0]')";
> for($i=1; $i<count($dele); $i++)
> $sql .= " or (entryID='$dele[$i]')";
> $res = mysql_query($sql, $connection);
> }
>
> Raul
>
> ----- Original Message -----
> From: "Davy Obdam" <info@davyobdam.com>
> To: "Php Mailinglist" <php-general@lists.php.net>; "Php-Windows
Mailing"
> <php-windows@lists.php.net>
> Sent: Monday, October 07, 2002 4:05 PM
> Subject: [PHP] Deleting multiple items from database using checkboxes
>
>
> > Hi people,.
> >
> > I have a guestbook admin page were i would like to delete one item
or
> > more items from the database if necessary. I have modified my normal
> > guestbookpage so that it has checkboxes in front of every entry.
This is
> > my code:
> >
> > <input type=\"checkbox\" name=\"dele[]\"
value=\"".$sql['entryID']."\">
> >
> > Now i can select multiple items. But i have tried to delete em, but
it
> > only deletes one item from the database, my query looks like this :
> > DELETE FROM gastenboek WHERE entryID=$dele . Can anyone help me.
Thanks
> > for your time.
> >
> >
> > Best regards,
> >
> > Davy Obdam,
> > mailto:info@davyobdam.com
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php