Re: PHP to delete mysql record.
| From: | Jay Greenspan | Date: | Tue, 12 Sep 2000 23:12:12 +0000 |
| Subject: | Re: PHP to delete mysql record. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16491@lists.php.net to get a copy of this message | ||
the value of the checkbox gets passed only if the checkbox
is checked.
What you'll need to do is give each checkbox the same name
and indicate that the checkboxes should become an
array when they reach PHP. for example:
<input type=checkbox name=people[] value=1>
Value needs to be something that uniquely identifies the
row.
Then in your PHP script, you will loop through the array, deleting
as you go.
if (is_array($people))
{
while (list ( $key, $value) = each ($people))
{
db_query("delete from table_name where id = $value")
}
}
-j
>Okay, I'm new but trying hard.
>PHP4 - Working Great on an OSX Server
>mysql - Working wonderfully on another OSX Server
>
>I've queried mysql and received back my database in HTML table. Now I
>want to make a form around the Table and a checkbox on the end of each
>record (I've already done that) and a button that say's "delete marked
>records" (done that too).
>
>Okay, here's the question "How do I right an PHP action that will return
>the same page and delete the marked records.
>
>+--------------+----+
>| Bill Clinton | X |
>+--------------+----+
>| Al Gore | X |
>+--------------+----+
>| Rush Limbaug | |
>+--------------+----+
>
>Say I wanted to delete those two guys at the top of my query result (by
>clicking on an checkbox) and return the resulting query:-) I'm
>supposing I'd make a "T" or "F" or "1" or "0" for
>the checked and null
>or unchecked box.
>
>+--------------+----+
>| Rush Limbaug | |
>+--------------+----+
>