it helps.
-Mike
[EMAIL PROTECTED]
http://www.soreye.com
- Original Message -
From: wesley grubbs:. [EMAIL PROTECTED]
To: [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
, 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
a
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
thanks guys for the aid.
in the end, i went with creating a check box that looks like this:
input type=checkbox name=del[] value=?php print($row[id]); ?
and the dirty work of deleting it looks like this::
foreach($_POST[del] as $val) {
$sql = DELETE FROM $tablename WHERE id = $val;
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]
olinux
--- wesley grubbs:. [EMAIL PROTECTED] wrote:
thanks guys for the aid.
in the end, i went with creating a check box that
looks like this:
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;
on 3/30/02 6:33 PM, wesley grubbs:. at [EMAIL PROTECTED] appended the
following bits to my mbox:
foreach($_POST[del] as $val) {
$sql = DELETE FROM $tablename WHERE id = $val;
Be very careful with this. If a user spoofs the form and adds the value for
del like this:
input type=checkbox