jeff5656 Posted July 17, 2010 Share Posted July 17, 2010 I have a table called states, but when I do a while loop to populated a dropdown, the dropdown has no content. I use this code for other dropdowns with no problems. Any ideas? <select name="state"><?php $q = "SELECT * FROM states ORDER BY states"; $result=mysql_query($q) or die (mysql_error()); $num_svcs=mysql_num_rows($result); while ($row = mysql_fetch_assoc ($result)) { ?><option value="<?php echo $row['abbrev'];?>"><?php echo $row['name'];?></option> <?php }?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/208062-dropdown-is-blank/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 17, 2010 Share Posted July 17, 2010 When you do a 'view source' of the page in your browser, what do you get? Quote Link to comment https://forums.phpfreaks.com/topic/208062-dropdown-is-blank/#findComment-1087613 Share on other sites More sharing options...
ndee Posted July 17, 2010 Share Posted July 17, 2010 By the looks of it, it seems like something's wrong with the MySQL query. Double check everything. Good luck; Andy. Quote Link to comment https://forums.phpfreaks.com/topic/208062-dropdown-is-blank/#findComment-1087614 Share on other sites More sharing options...
jeff5656 Posted July 17, 2010 Author Share Posted July 17, 2010 Wow you are smart. The error was stuck inside the dropdown in HTML so I never saw it untik I viewed the source. Very clever of you :-) <select name="state">Unknown column 'states' in 'order clause' I turns out the fieldname was "name" not state. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/208062-dropdown-is-blank/#findComment-1087615 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.