SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Select Menu

  1. #1
    SitePoint Member
    Join Date
    May 2001
    Location
    St. Louis
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Select Menu

    I am having trouble coding an HTML Form Select Menu in PHP.

    I my other form fields pulling from my MySQL database fine, but I need a drop down menu for a couple items, so my end user doesnt mess up editing certain fields.

    I am a newbie, so the simpler the better :-)

    Thanks,
    Ben

  2. #2
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to know how to create a HTML form? If so, that is how you do it: (A very basic one.)

    Code:
    <select name="something_id">
    <option value="1" selected>This is the default value
    <option value="2">Look, another value!
    </select>
    This needs to be inside a form tag to work (so it knows which page to submit to).

  3. #3
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this might help a little better:

    PHP Code:
    // connect to database

    echo('<select name="menu" size="1">');
    $sql "SELECT * FROM table";
    $result mysql_query($sql);
    while(
    $row mysql_fetch_array($result)){
        
    extract($row);
        echo(
    '<option value="id">$name</option>');

    This might help!

    God Bless,

    Alex Stanton
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •