nashsaint Posted June 1, 2008 Share Posted June 1, 2008 I have a drop-down menu populated from sql query. After the user selected something, he can come back anytime in this page to change whatever he wants from the drop-down list. How can I configure the script so that when the user comes back to this page, php will pull out the entry that the user first selected and display it as the first option under the list? Quote Link to comment https://forums.phpfreaks.com/topic/108252-sort-drop-down-menu-to-display-selected-item-first/ Share on other sites More sharing options...
nashsaint Posted June 1, 2008 Author Share Posted June 1, 2008 This is my code: $sql = "SELECT * FROM job_log_pull"; $res = mysql_query($sql); if(mysql_num_rows($res) > 0){ echo("<select name=\"make\">"); while($row = mysql_fetch_object($res)){ echo("<option value=\"$row->make_id\">$row->pc</option>"); } echo("</select>"); } else { echo("<i>No values found.</i>"); } Quote Link to comment https://forums.phpfreaks.com/topic/108252-sort-drop-down-menu-to-display-selected-item-first/#findComment-554917 Share on other sites More sharing options...
hansford Posted June 1, 2008 Share Posted June 1, 2008 you'll have to start a session and then hold the value selected in a session variable like so $_SESSION['selection'] = "users selection"; Quote Link to comment https://forums.phpfreaks.com/topic/108252-sort-drop-down-menu-to-display-selected-item-first/#findComment-554936 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.