Form with <select name=test multiple=yes>

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Form with <select name=test multiple=yes>

Post by kingconnections »

Ok so I got this form that allows multiple selections. Up to this point I have been using the standard post and get methods for retrieving the values. But on this one it only returns 1 of the multiple selected items. How can I approach this with my get or post statements.

ie

They selected test1 and test2. Normally I do:

Code: Select all

$type= $_POST['type'];
$type would be test2.

any ideas.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Code: Select all

<select name="test[]" multiple="yes">
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

So I just retrieve the the number of values in that array ?

Code: Select all

$type= $_POST[type[0]]; 

$type2= $_POST[type[1]];
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

$_POST[type][0]
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

Thanks guys!
Post Reply