Birdmansplace Posted July 18, 2011 Share Posted July 18, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/242241-simple-drop-down/ Share on other sites More sharing options...
TeNDoLLA Posted July 18, 2011 Share Posted July 18, 2011 Have you checked you page source after php has generated the page? Does it look like valid HTML, maybe theres a hint what is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/242241-simple-drop-down/#findComment-1244004 Share on other sites More sharing options...
Birdmansplace Posted July 18, 2011 Author Share Posted July 18, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242241-simple-drop-down/#findComment-1244006 Share on other sites More sharing options...
TeNDoLLA Posted July 18, 2011 Share Posted July 18, 2011 Tested that and in that piece of code there is nothing wrong. There must be something else wrong in your HTML. Quote Link to comment https://forums.phpfreaks.com/topic/242241-simple-drop-down/#findComment-1244012 Share on other sites More sharing options...
Birdmansplace Posted July 18, 2011 Author Share Posted July 18, 2011 thanks for the pointers. was having <select name showing up twice. Quote Link to comment https://forums.phpfreaks.com/topic/242241-simple-drop-down/#findComment-1244014 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.