I have a form which has 20 selects. These are all the players in a tournament who could finish in the top 20 places, 1st - 20th. The drop down is a list of names from my players database. Using php I read the mysql table for a list of "players" and create a drop down with the full list. The list choices are the same for all 20 selects. The list of 20 is preceded by the tournament identifiers, date, tournament number which have labels. Using GET I see the string which is created:

tdate=09%2F11%2F2009&tnumber=on&Select1=Mickey+Mouse&Select1=Daisy+Duck&Select1=Daisy+Duck&Select1=Pluto&Select1=Daisy+Duck&Select1=Mickey+Mouse&Select1=Daisy+Duck&Select1=Daisy+Duck&Select1=Mickey+Mouse&Select1=Daisy+Duck&Select1=Pluto&Select1=Daisy+Duck&Select1=Pluto&Select1=Daisy+Duck&Select1=Mickey+Mouse&Select1=Mickey+Mouse&Select1=Daisy+Duck&Select1=Pluto&Select1=Daisy+Duck&Select1=Pluto&Submit1=submit

I retrieve the tdate and tnumber with:

$tdate = $_REQUEST['tdate'];
$tnumber = $_REQUEST['tnumber'];

But I do not know how to retrieve the multiple Select1= values.
Since I have 20 different selects, is it possible to insert a different key along with the value?

This is the code which displays one of the selects (places 1st - 20th:

<div id="label">1st Place</div>
<div id="lookup"><?php get_player_selections($tavern_id, "first");?></div>

And this is the php function which creates and populates the select drop down.

function get_player_selections($tavern_id,$place){
    global $connection; 
    $query= "SELECT * FROM players WHERE tavern_id='".$tavern_id."' ORDER BY name ASC";
    $player_set= mysql_query($query);
    confirm_query ($player_set);

    $rows = mysql_num_rows($player_set);
    $i=0;
    echo "<select name='Select1'>";
    while ($i < $rows) {
       $data = mysql_fetch_array($player_set);
       echo "<option>".$data['name']."</option>";
       $i++;
    }
    echo "</select>";
}

You can't, the form fields must have separate names. If you have a bunch of Select1=blah in the URL only the last one will actually assign the value.

function get_player_selections($tavern_id,$place){
		global $connection;	
		$query= "SELECT * FROM players WHERE tavern_id='".$tavern_id."' ORDER BY name ASC";
		$player_set= mysql_query($query);
		confirm_query ($player_set);
		
		$rows = mysql_num_rows($player_set);
		$i=0;
		echo "<select name='Select1'>";
		while ($i < $rows) {
		   $data = mysql_fetch_array($player_set);
		   echo "<option>".$data['name']."</option>";
		   $i++;
		}
		echo "</select>";
}

Why don't you use different names for each select? You seem to have an unused $place value in your function
Why not name the select like so:

<select name='Select".$place."'>

Simon you are the best.
I had to experiment with the exact syntax to get what I needed but you put me on the track. Here is what I settled on:

echo "<select name='Select1[$place]'>";

Which yielded

tdate=09%2F11%2F2009&tnumber=2&Select1[first]=Daisy+Duck&Select1[second]=Daisy+Duck

and so forth. Then I could retrieve the values with:

$first = $_REQUEST ['Select1']['first'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.