RE: [PHP] Help with Multiple Checkboxes
| From: | John W. Holmes | Date: | Sat, 22 Feb 2003 18:26:22 +0000 |
| Subject: | RE: [PHP] Help with Multiple Checkboxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136649@lists.php.net to get a copy of this message | ||
> I am having some difficulty getting a list of check boxes to work
> properly. I have dug through the list archives, usenet, PHP Manuals,
> etc. and still I am unable to process multiple checkboxes from a form
> submission properly. The following is what I am running into.
>
> Form:
> <input name="add" type="checkbox" id="add[]"
> value="179">
> <input name="add" type="checkbox" id="add[]"
> value="409">
> <input name="add" type="checkbox" id="add[]"
> value="2090">
>
> PHP:
> for ($i = 0; $i < count($_POST['add']); $i++)
> {
> echo $_POST['add'][$i];
> echo "<br>\n";
> }
>
> Output:
> 2
> 0
The name attribute should be "add[]", not the ID.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/