ashrobbins87 Posted March 13, 2009 Share Posted March 13, 2009 I'm getting very frustrated with this, I've searched all over for a solution for this, with differing responses. I want a list of names from a database to populate a drop down list. The code I have at the moment is.... $getUsers_sql ="SELECT id, firstname FROM cms_users"; $getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error()); $getUsers_sql ="SELECT id, firstname FROM cms_users"; $getUsers_res = mysqli_query($mysqli, $getUsers_sql)or die(mysqli_error()); echo '<select name="users">'; while ($row = mysqli_fetch_assoc($result)) { echo '<option value="' . $row['id'] . '">' . $row['firstname'] . '</option>'; } echo '</select>'; Quote Link to comment https://forums.phpfreaks.com/topic/149258-solved-populating-drop-down-box-from-database/ Share on other sites More sharing options...
Maq Posted March 13, 2009 Share Posted March 13, 2009 Change this line: while ($row = mysqli_fetch_assoc($getUsers_res)) Quote Link to comment https://forums.phpfreaks.com/topic/149258-solved-populating-drop-down-box-from-database/#findComment-783795 Share on other sites More sharing options...
Silverado_NL Posted March 13, 2009 Share Posted March 13, 2009 well u havent stated anything wrong, but im guessing its got to do with where you are refering to the mysql source. $getUsers_res is used to set resource. but in the while loop your using $result. Quote Link to comment https://forums.phpfreaks.com/topic/149258-solved-populating-drop-down-box-from-database/#findComment-783799 Share on other sites More sharing options...
Silverado_NL Posted March 13, 2009 Share Posted March 13, 2009 meh to late Quote Link to comment https://forums.phpfreaks.com/topic/149258-solved-populating-drop-down-box-from-database/#findComment-783800 Share on other sites More sharing options...
ashrobbins87 Posted March 13, 2009 Author Share Posted March 13, 2009 Thanks guys, cant believe I couldn't see that! Quote Link to comment https://forums.phpfreaks.com/topic/149258-solved-populating-drop-down-box-from-database/#findComment-783844 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.