If I understand your question, when editing an existing record where StateID = "CA", you want the drop-down to show "California" as selected.
You need to add a little code into your while loop to echo "SELECTED" into the appropriate "option" tag. -Dan --- Steve Fitzgerald <[EMAIL PROTECTED]> wrote: > I have the below code that populates a drop down list. The code will > correctly insert the value $StateID into another a table. The problem > I am > running into is that when I select the record to edit the > drop-downlist has > the first option as the value instead of what the corresponding > StateID in > the column reads. How can I correct this? The form to insert and edit > have > the below code and correctly insert the StateID. I tried to write and > if > statement to state that if the StateID were == to the StateID in he > table > then print selected, but I think I am missing something. > > Any suggestions? > > Thanks. > > <?php > > // populates state drop-down list > > $get_stateid_query = mysql_query("SELECT * FROM State INNER JOIN > RaceResults > ON State.StateID WHERE RaceID='$RaceID'"); > > echo " <select name=\"StateID\">\n"; > > while ($myrow = mysql_fetch_array($get_stateid_query)) { > > echo ' <option > value="'.$myrow["StateID"].'">'.$myrow["StateName"]."</option>\n"; > } > echo " </select>\n"; > ?> > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php