Re: checkbox arrays and validation
| From: | John Holmes | Date: | Tue, 05 Oct 2004 10:47:15 +0000 |
| Subject: | Re: checkbox arrays and validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198654@lists.php.net to get a copy of this message | ||
Angelo Zanetti wrote:
but what I want to clarify is that if I change my PHP echo statement to: echo("<input type=checkbox name=chkmodels value=" . $row['models_id'] . ">" . $row['models_type'] . "<br>"); basically without the [] then it is still recognised as an array. But when the array is passed back it is returned as a string separated by commas. Then I should use the split() function to create an array.If you leave off the [], then only the last checkbox value remains in $_POST['chkmodels']. It is not passed as a comma separated string. If you look at the query string, you'll see something like this: ?chkmodels=1&chkmodels=2 which means PHP makes $_POST['chkmodels'] equal to 1 for the first variable, then sets the same $_POST['chkmodels'] equal to 2 for the second variable in the query string. End result is one value (not an array) remaining in $_POST['chkmodels']. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com