SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2012
    Location
    BD
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make drop down menu using PHP MYSQL ? please help

    hello,
    i am facing prob to create drop down menu using php mysql. i write a code but it showing only 1 row. i want to create a drop down menu from my database table and in drop down menu all data will be show in one drop down . please help me , Here is my code:
    Code:
    $result = mysql_query("SELECT * FROM members");
    while($row = mysql_fetch_array($result)){
    $b=$row["login"];
    echo '<select>';
    echo '<option>';
    echo $b++;
    echo '</option>';
    echo '</select>';
    }
    i want a drop down list from my data base. thanks in advance

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Essentially:

    PHP Code:
    $result mysql_query("SELECT * FROM members");

    echo 
    '<select>';  // start your select box before you loop kicks off


    while($row mysql_fetch_array($result)){

    // now we are inside the loop so do stuff 
    // repeatedly until the array ends

    $b=$row["login"];
    echo 
    '<option>';
    echo 
    $b++;  // what for?
    echo '</option>';

    }


    echo 
    '</select>';  //end your select box now the loop has finished 
    Not sure if this is your case exactly, but often when outputting PHP as HTML elements and this do not seem as they should, go and look at the HTML Source code of the page --- this will often turn up basic errors, failing to close tags etc.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2012
    Location
    BD
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ow sorry b++ was unnessesary and i found my fault... i got the script bro tnx alot for help me @Cups bro


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
  •