Re: checkbox arrays and validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux