Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a list box Array

Status
Not open for further replies.

sarcus25

Programmer
Apr 14, 2005
27
0
0
Hi i have a list box named "los". What I want to do is display each value in the list box that was selected. In the query string I can see the values for each item selected in the list box but if I get a count like so: "count($_GET['los'])" it displays a value of "1" even through I have just selected and submitted more than one item to that script. It always just displays that last Item that I selected in that list box. Below is a sample of the code that I am using to try to break up and display the list box array.


foreach($_GET['los'] as $key => $value){

echo $key,": ", $value,"<br>";

}


Thanks in advance
 
Never Mind found a simular post on the net. The problem was that the name of the list box had to be followed with brackets
ex. los[] the brackets specify that this is an array. Hope this doesn't drive anyone as crazy as this drove me.

Cheers,
 
Rename your list box to be called [tt]los[][/tt]. Then los will be an array which will hold all the selected values and you can reference them via [tt]$_GET['los'][0][/tt] and subsequent numbers or use a for loop to loop through them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top