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:

$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 :slight_smile:

Essentially:


$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.

ow sorry b++ was unnessesary and i found my fault… i got the script bro :slight_smile: tnx alot for help me :slight_smile:@Cups bro