pneudralics Posted April 8, 2009 Share Posted April 8, 2009 I got it to display but how do I make it so it's not all one line? The below will show all the results in one line. <select name="category"> <option> <?php $querycategory = 'SELECT * FROM category'; if ($cresult = mysql_query ($querycategory)) { while ($crow = mysql_fetch_array ($cresult)) { $category = $crow['category']; echo "$category"; } } ?> </option> </select> Link to comment https://forums.phpfreaks.com/topic/153199-solved-how-do-i-get-php-to-display-results-in-a-form-drop-down-menu/ Share on other sites More sharing options...
wildteen88 Posted April 8, 2009 Share Posted April 8, 2009 Your <option></option> tags need to be within your while loop, while ($crow = mysql_fetch_array ($cresult)) { $category = $crow['category']; echo "<option>$category</option>"; } Only the <select></select> tags need to be outside of your loop Link to comment https://forums.phpfreaks.com/topic/153199-solved-how-do-i-get-php-to-display-results-in-a-form-drop-down-menu/#findComment-804768 Share on other sites More sharing options...
pneudralics Posted April 8, 2009 Author Share Posted April 8, 2009 Your <option></option> tags need to be within your while loop, while ($crow = mysql_fetch_array ($cresult)) { $category = $crow['category']; echo "<option>$category</option>"; } Only the <select></select> tags need to be outside of your loop Thanks Link to comment https://forums.phpfreaks.com/topic/153199-solved-how-do-i-get-php-to-display-results-in-a-form-drop-down-menu/#findComment-804769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.