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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.