Jump to content


Create Drop Down Menu From List in SQL

  • Please log in to reply
1 reply to this topic

#1 OCHE1976

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 03 April 2006 - 07:27 PM

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?


#2 jvrothjr

  • Members
  • PipPipPip
  • Advanced Member
  • 300 posts
  • LocationOhio

Posted 03 April 2006 - 07:37 PM

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

If you understand everything you know nothing!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users