Jump to content

Sort Drop down menu to display selected item first?


nashsaint

Recommended Posts

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? 

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>");
                    }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.