Re: deleting multiple items from a database
| From: | Curt Zirzow | Date: | Wed, 13 Oct 2004 21:35:06 +0000 |
| Subject: | Re: deleting multiple items from a database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199440@lists.php.net to get a copy of this message | ||
* Thus wrote Adil:
>
> As far as the code goes what I'm doing is retrieving each record from the
> database and assigning the "value" attribute of each checkbox the unique id
> from the database. From that point on, when a checkbox is checked and the
> delete button is pressed, I push each checked unique id into an array and
> then call a function that cycles through the array and deletes each database
> entry. The last step is a simple page refresh. I'm posting some of the
> more relevant sections of the code I've used below:
>
> echo "<form action=\"{$_SERVER['PHP_SELF']}\"
> method=\"post\">";
> //form declaration
> echo "<input type=\"submit\"
> value=\"Delete\"value=\"Submit\">";
> //The delete button
> <td><input type=\"checkbox\"
>
> value=\"{$row['upload_id']}\"></input><br/></td>";
> //This is what the
> checkbox is coded as
This is your problem, you need to give the checkbox a name:
<input type="checkbox" name="stack[]" value="...">
When the form is submitted $_POST['stack'] will contain an array of
items that were checked.
Curt
--
Quoth the Raven, "Nevermore."