Problem with dropdown boxes in PHP
Posted: Tue Jun 28, 2005 11:26 pm
I have a drop down box that does a SELECT *, but it doesn't display the first record. Then it marks the record it doesn't show as the record selected, no matter what I select. below is some of my code. Can anyone help me solve this riddle.
Here is the SELECT call.
Here is the code for the drop down.
Here is what I am trying to send to the db table and as you can see, without even selecting anything, it has selected the row that does not show up in the drop down.
Here is the SELECT call.
Code: Select all
$queryplayers = " SELECT * FROM `players` ORDER BY `last_name` ASC";
$resultplayers = mysql_query($queryplayers) or die ("Error in query: $queryplayers. " . mysql_error());
$row3 = mysql_fetch_array($resultplayers);
extract($row3);Code: Select all
<select name="player_id" height=20 multiple>
<option selected>---- Please Select a Player ----</option><?php
while ( $rowplayers= mysql_fetch_array($resultplayers)){extract($rowplayers);
echo "
<option value='$player_id'>$last_name, $first_name</option>"
;}?>
</select>Code: Select all
<input type="hidden" name="player_id" value="00178">
<input type="hidden" name="first_name" value="Rohan">
<input type="hidden" name="last_name" value="Allwood">
<input type="hidden" name="home_town" value="Pinehurst, North Carolina">