refiking Posted April 2, 2008 Share Posted April 2, 2008 I am trying to place all the items from the sql query in a drop down menu. What is the correct way to code this? Here is what I have: $league = mysql_query("SELECT * FROM dlg WHERE lid = '$lid'")or die(mysql_error()); while ($row3 = mysql_fetch_array($league)){ $dlg = $row3['lname']; ?> <form action="index.php" method="post"> <select name="lid"> <option value="<?echo $lid.'>'.$dlg.'"';?></option> </select> <input type="Submit" value="Select League"> </form> Link to comment https://forums.phpfreaks.com/topic/99233-drop-down-menu-using-db-records/ Share on other sites More sharing options...
trq Posted April 2, 2008 Share Posted April 2, 2008 <form action="index.php" method="post"> <select name="lid"> <?php if ($league = mysql_query("SELECT * FROM dlg WHERE lid = '$lid'")) { if (mysql_num_rows($legue)) { while ($row3 = mysql_fetch_array($league)){ $dlg = $row3['lname']; echo " <option value=\"$lid\">$dlg</option>"; } } } ?> </select> <input type="Submit" value="Select League"> </form> Link to comment https://forums.phpfreaks.com/topic/99233-drop-down-menu-using-db-records/#findComment-507716 Share on other sites More sharing options...
refiking Posted April 2, 2008 Author Share Posted April 2, 2008 It doesn't show the options in the drop down menu. I put a line in to echo $lid and $dlg and the values returned the records from the DB. So, I know the variables work. Is there something I missed in the code? Link to comment https://forums.phpfreaks.com/topic/99233-drop-down-menu-using-db-records/#findComment-507738 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.