Jump to content

Create Drop Down Menu From List in SQL


OCHE1976

Recommended Posts

I have a members list in a database. I have some filling in information all the time about these members. I do not want him to have to enter the name all the time. I would like to give him a drop down menu with all the names. However, this member list changes all the time. If the name is not in the table, I will give him the ability to enter a new name into the database. That I know is easy.

So, to the question: How would I create a drop down menu from a list within an SQL Database?

Thanks,
David
Link to comment
Share on other sites

[code]
    mysql_select_db ("databasename");
         echo "User : <select name=UserID><option value='.'>--Select One--</option>";
         $UserTableQuery = mysql_query ("select DISTINCTROW Fieldname from Tablename order by Fieldname");
         while ($UserTableRow=mysql_fetch_array($UserTableQuery)) {
         echo "<option value='".$UserTableRow[Fieldname]."'>".$UserTableRow[Fieldname]."</option>\n"; }
         echo "</select><p>";
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.