I am trying to create a dynamic drop down list using PHP and mysql database. I have written the following code and its giving me the output, but the problem is that its show
Get rid of the inner foreach loop... it is doing nothing for you and move the start and end select tags outside of the while loop.
$select_query= "Select name from category"; $select_query_run = mysql_query($select_query); echo ""; while ($select_query_array= mysql_fetch_array($select_query_run) ) { echo "".htmlspecialchars($select_query_array["name"]).""; } echo "";