Re: retrieve multiple select
| From: | Shawn McKenzie | Date: | Mon, 02 Mar 2009 21:09:47 +0000 |
| Subject: | Re: retrieve multiple select | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289071@lists.php.net to get a copy of this message | ||
PJ wrote:
> I'm sure this has been hashed over and over on the web, only I can't
> find anything that makes sense or the explanations given have been
> erroneous.
> This is what I am trying:
> <select name="($categoriesIN).'[]'" multiple>
> <OPTION>Choose Categories...</option>
> <OPTION VALUE="1">History
> <OPTION VALUE="2">Temples
> <OPTION VALUE="3">Pharaohs and Queens
> <OPTION VALUE="4">Cleopatra
> <OPTION VALUE="5">Mummies
> </SELECT>
> for ($i = 0; $i < count($_POST['categoriesIN']); $i++)
> echo $categoriesIN[$i];
>
> OR SHOULD IT BE: <select name="$categoriesIN[]" multiple size="5">
>
> BUT NEITHER WORKS. I have tried print_r, while, and other off the wall
> stuff I found on the Weird Warped Web! It's unreal how much crap there
> is out there... :-(
>
> I understood that the input from a select dropdown box was an array...
> OK, so how do I retrieve the array and verify what was entered? I
> suppose if I could verify, then I should be able to retrieve and INSERT etc.
> As I delve deeper into this the more I know the "horseman knew her" ... :-)
> Please elucidate, enlighten me from my erring ways ...
Just like the last time you asked this, you need to use:
<select name="categoriesIN[]" multiple>
Then it would be easy to:
foreach ($categoriesIN as $category) {
echo $category;
}
--
Thanks!
-Shawn
http://www.spidean.com