kev wood Posted April 1, 2009 Share Posted April 1, 2009 i have the following code which populates a drop down menu with query results from a mysql db. i got the page working fine. i have now change the way the page so that it loads the content into a div tag but since i have done this the code is no longer populating the drop down menu. here is all the code for the contnet which is loaded in the div tag case 10: echo''; $db = "pipdb"; $con = mysql_connect("localhost","pip","piptables")or die(mysql_error()); mysql_select_db($db)or die(mysql_error()); $query="SELECT id, title FROM training"; $result = mysql_query($query) or die(mysql_error()); $options = ""; while ($row=mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; $options.="<OPTION VALUE=\"$id\">".$title; } echo'<form action=\"insert_interest.php\" method=\"POST\"> <h4>Select which course you would like to register your interest in</h4> <h5>Option 1</h5> <select name=\"radio\"> <OPTION VALUE=0>Please select an option <?=$options?> </select> <h5>Option 2</h5> (only select more options if needed)<br /> <br /> <select name="radio1"> <OPTION VALUE=0>Please select an option <?=$options?> </select> <h5>Option 3</h5> <select name="radio2"> <OPTION VALUE=0>Please select an option <?=$options?> </select> <br /><br /><h4>Enter the required information</h4> <b>Name:</b><br /> <input type="text" name="name" /><br /> <b>Address:</b><br /> <textarea cols="50" rows="7" name="address" onkeyup="textLimit(this, 150);"></textarea><br /> <b>Housing Association:</b><br /> <input type="text" name="housing" /><br /> <b>Email:</b><br /> <input type="text" name="email" /><br /> <br /> <input type="submit" value="Register Interest" /> </p> </form>'; break; this is the section of code that is not working anymore <h5>Option 1</h5> <select name=\"radio\"> <OPTION VALUE=0>Please select an option <?=$options?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/152045-solved-drop-down-not-being-populated/ Share on other sites More sharing options...
kev wood Posted April 1, 2009 Author Share Posted April 1, 2009 sorted. i have to just echo the options as follows echo $options Quote Link to comment https://forums.phpfreaks.com/topic/152045-solved-drop-down-not-being-populated/#findComment-798498 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.