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

    Join Date
    Jul 2000
    Posts
    1
    Rep Power
    0
    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
    Posts
    43
    Rep Power
    15
    This assumes you have a table in a database like this with data in it:

    CREATE TABLE info (
    ID INTEGER NOT NULL AUTO_INCREMENT,
    title VARCHAR(255),
    PRIMARY KEY(ID)
    );
    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>

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

    </select>
    </form>

    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.


    ------------------
    lhallusa
    webpatron.com

Similar Threads

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

IMN logo majestic logo threadwatch logo seochat tools logo