Re: processing form with unknown number of checkboxes, each with a unknown name.
| From: | Tim Ward | Date: | Sun, 02 Feb 2003 12:31:11 +0000 |
| Subject: | Re: processing form with unknown number of checkboxes, each with a unknown name. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133988@lists.php.net to get a copy of this message | ||
howabout making the checkboxes an array i.e.
<INPUT TYPE="checkbox" name="checkbox[<?php echo($row[0])?>]"
VALUE="YES">
then when processing ...
foreach($_REQUEST["checkbox"] as $checkbox)
{ ...
}
Tim Ward
http://www.chessish.com
mailto:timward@chessish.com
----- Original Message -----
From: anders thoresson <listor@thoresson.net>
To: <php-general@lists.php.net>
Sent: Sunday, February 02, 2003 12:28 PM
Subject: [PHP] processing form with unknown number of checkboxes, each with
a unknown name.
> Hi,
>
> I building a form which will be used to set access rights to different
> parts of my web album. When editing the settings for each album, like the
> albums name and wether or not everyone should be allowed to upload
pictures
> to it, I also present a list of checkboxes to the administrators. One
> checkbox for each registred user. If checked, to user is allowed to view
> the pictures, if not check, no pictures show.
>
> The checkbox part of the form I build uses this code:
>
> db_connect($dbuser, $dbpassword, $dbdatabase);
> $query = "SELECT userid FROM members";
> $result = mysql_query($query);
> while($row = mysql_fetch_array($result)) {
> echo($row[0]);
> ?>
> <INPUT TYPE="checkbox" name="<?php echo($row[0])?>"
> VALUE="YES">
>
>
> But how do I process this form when saving the settings for the album?
For
> the forms I've built so far, I've known what information I can find in
> $_REQUEST['']. But this time, I don't know how many checkboxes there are,
> and what their names will be. How do I do this?
>
> Is the form ok, or is a bad form design the reason I can't figure out
what
> to form processing code should be?
>
> --
> anders thoresson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>