RE: [PHP] Process array after form submission problem
| From: | Steve Jackson | Date: | Fri, 14 Feb 2003 06:54:36 +0000 |
| Subject: | RE: [PHP] Process array after form submission problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-135554@lists.php.net to get a copy of this message | ||
Cheers,
Solved the problem exactly how I wanted it.
Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com
stephen.jackson@violasystems.com
Mobile +358 50 343 5159
> -----Original Message-----
> From: Matt Schroebel [mailto:MSchroebel@hsus.org]
> Sent: 13. helmikuuta 2003 21:29
> To: Php-General; Steve Jackson
> Subject: RE: [PHP] Process array after form submission problem
>
>
>
>
> > -----Original Message-----
> > From: Steve Jackson [mailto:steve@webpage.co.uk]
> > Sent: Thursday, February 13, 2003 2:10 PM
> > To: Php-General
> > Subject: [PHP] Process array after form submission problem
> >
> >
> > Hi,
> >
> > My problem is that I have a dynamic form with vars which I
> > want to process.
> >
> > The variables are checkbox names with a variable number of
> > checkboxes but
> > all currently have the same variable name.
> >
> > ie.
> > <form action='process.php' method='post'>
> > <input type = text name = user value = name>
> > <input type = checkbox name = grant value =
> "{$array["code"]}"> <input
> > type = checkbox name = grant value = "{$array["code"]}">
> <input type =
> > checkbox name = grant value = "{$array["code"]}">
> >
> > The array code works fine in that the values reflect what is
> > in the DB.
> >
> > I understand that $grant will be an array? (am I right?) so
> > how do I use PHP
> > to look at $grant as an array in my processing script rather than an
> > ordinary variable? I can get the DB to update if there is
> > only one checked
> > box but otherwise it updates the DB with the value of the
> > last checkbox.
> Add [] to the end of the item name like:
> <input type = checkbox name = grant[] value = "{$array["code"]}">
>
> <?php
> $grant = $_POST['grant'];
> if (is_array($grant)) {
> echo 'Items checked:<br>';
> foreach ($grant as $value) {
> echo "$value<br>";
> }
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>