RE: [PHP-DB] Selecting Drop Down Value From DB to Edit

From: Date: Wed, 27 Mar 2002 13:13:55 +0000
Subject: RE: [PHP-DB] Selecting Drop Down Value From DB to Edit
Groups: php.db 
Request: Send a blank email to php-db+get-17943@lists.php.net to get a copy of this message
I'm trying to decipher: 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 What exactly is happening? Run the script, do a View Source on the resulting page; show us the HTML generated. -----Original Message----- From: Steve Fitzgerald [mailto:sf@mnetsys.com] Sent: Tuesday, March 26, 2002 5:22 PM To: php-db@lists.php.net Subject: [PHP-DB] Selecting Drop Down Value From DB to Edit 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

« previous php.db (#17943) next »