Re: Re: Variable name as a string
| From: | Chris | Date: | Thu, 28 Aug 2008 03:51:55 +0000 |
| Subject: | Re: Re: Variable name as a string | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278852@lists.php.net to get a copy of this message | ||
Micah Gersten wrote:
You cannot have anything in the brackets for the name in a checkbox group. The brackets specify that it is an array. The name of the array is the key in $_POST that contains the values of the checkbox group that were checked. You can have as many groups as you like.Eh? Course you can. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="checkbox" name="data[field_name][]" id="my_checkbox_1" value="1" > Val 1 <input type="checkbox" name="data[field_name][]" id="my_checkbox_2" value="2" > Val 2 <input type="checkbox" name="data[field2][]" id="field1" value="1" > Val 1 (Field 1) <input type="checkbox" name="data[field2][]" id="field2" value="2" > Val 2 (Field 2) <input type="submit"> </form> <pre> <?php print_r($_POST); You end up with a multi-dimensional array. Array (
[data] => Array
(
[field_name] => Array
(
[0] => 1
)
[field2] => Array
(
[0] => 1
[1] => 2
)
)) -- Postgresql & php tutorials http://www.designmagick.com/