Jump to content

simple drop down


Birdmansplace

Recommended Posts

I have been trying to get a dropdown menu to load names from a db.    all names are in one table in one field.  this what i got so far.  it shows the drop down and all the names out side of it.

 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM $tbl_name ORDER BY stitle";
$result=mysql_query($sql);

$options="";
  
  while ($row=mysql_fetch_array($result)) {
  
  	$id=$row["stitle"];
  	$options.="<OPTION VALUE=\"$id\">".$id.'</option>';
  }
  ?>
  
  <SELECT NAME=id>
  <? echo $options ?>
  </SELECT>

Link to comment
https://forums.phpfreaks.com/topic/242241-simple-drop-down/
Share on other sites

viewing page source i see that it is right

 

 <SELECT NAME=id>
  <OPTION VALUE="ALICIA">ALICIA</option><OPTION VALUE="Randy">Randy</option><OPTION VALUE="ty">ty</option><OPTION VALUE="wendy">wendy</option>  </SELECT>

 

but all the names show up out side the dropdown and theres nothing inside it. 

 

the drop down shows up with nothing in it and all the names show up to the right out side of it.

Link to comment
https://forums.phpfreaks.com/topic/242241-simple-drop-down/#findComment-1244006
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.