faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

39 of 57 people (68%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can I pass multiple selections from a drop down menu?

Feb 14th, 2003 06:37
C. Collins, Todd Scarl, Julian Laster,


The FORM SELECT:


<select name="var[]">  // the [] sets val as an array 


  <option name="1">one</option>


  <option name="2">two</option>


</select>




The PHP:


foreach ($var as $value)


  {


    //perform action


  }




This simply loops through $var (your selections) allowing you to do 


what you like with them.