1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Rep Power
    I am working on a site that is going to be listing diners in my town and local cities. I have been reading up the tutorial on the webmasterbase.com site with PHP and mysql. Well I have been going thru that pretty good. But I have one question. How would i setup a pulldown menu so that when you would say select munster it would go to the database and pull the information out of the database and put it on the page.

    I am not clear with the way to set up the pulldown menu. I know how i could do this with just a standard link but not a pulldown menu. Thank you for your help in advance.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Rep Power
    This assumes you have a table in a database like this with data in it:

    CREATE TABLE info (
    title VARCHAR(255),
    Put following in say index.php3. Normally doesn't work in a .html file. Must end with .php , .php3 etc. depending on server configs.
    Then to retrieve it in a select drop down:
    // $mysql_link = connection stuff varies. Only need to connect one time for the whole script so you may want to put this at the beginning of the page instead with <?php $mysql_link = connect_to_database functions etc. php?>.

    inside index.php3 put:
    <form action="somefile.php3" action="GET">
    <select name="mySelectVariable">
    <option selected>- Select Something -</option>

    // For Select
    $query = "SELECT * FROM info ORDER BY title";
    $result = mysql_query($query, $mysql_link);
    while($row=mysql_fetch_array($result)) {
    print("<option value=".$row["ID"].">".$row["title"]."</option>n");


    Then the $mySelectVariable will be passed to somefile.php3 with the value of ID from the database
    Usage of database functions vary.

    That's about it.


Similar Threads

  1. Replies: 7
    Last Post: March 17th, 2004, 05:39 AM
  2. Dynamic search, php mysql
    By jonny5005 in forum PHP Development
    Replies: 5
    Last Post: January 26th, 2004, 10:17 PM
  3. PHP Drop Down menus linked to MYSQL
    By WillyWoo in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 11:45 AM
  4. Replies: 3
    Last Post: January 21st, 2004, 12:05 AM
  5. drop down php menu value wont show
    By alexmasters in forum PHP Development
    Replies: 2
    Last Post: January 19th, 2004, 05:31 AM

IMN logo majestic logo threadwatch logo seochat tools logo