Ph0enix Posted May 20, 2006 Share Posted May 20, 2006 Hi, i want to make a drop down menu that has thigs from my database in it.I have people registering on my website so it is annoying to add them in on my own. So how would i get everybody user_name into a drop down menu. Please help! thanks Link to comment https://forums.phpfreaks.com/topic/10077-drop-down-menu/ Share on other sites More sharing options...
zq29 Posted May 20, 2006 Share Posted May 20, 2006 You can just pull the required information from your database, loop through it and create the entereies in the select box. Here's an example:[code]<?php$result = mysql_query("SELECT `name`,`id` FROM `table`") or die(mysql_error());echo "<select name='names'>";while($row = mysql_fetch_assoc($result)) { echo "<option value='$row[id]'>$row[name]</option>";}echo "</select>";?>[/code] Link to comment https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-37482 Share on other sites More sharing options...
Ph0enix Posted May 20, 2006 Author Share Posted May 20, 2006 Well its sort of working.When i put this code in it works showing the points for users..$result = mysql_query("SELECT `points` FROM `points`") or die(mysql_error());echo "<select name='names'>";while($row = mysql_fetch_assoc($result)) { echo "<option value='$row[points]'>$row[points]</option>";}echo "</select>";(the table is called points)but when i try this code it comes up with the right amount of options but they all say Array[user_name]$result = mysql_query("SELECT `user_name` FROM `points`") or die(mysql_error());echo "<select name='names'>";while($row = mysql_fetch_assoc($result)) { echo "<option value='$row[user_name]'>$row[user_name]</option>";}echo "</select>";Do you know whats wrong? Link to comment https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-37492 Share on other sites More sharing options...
Ph0enix Posted May 21, 2006 Author Share Posted May 21, 2006 [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Link to comment https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-37634 Share on other sites More sharing options...
RSprinkel Posted May 28, 2006 Share Posted May 28, 2006 Hi,I am trying to use the code listed by SemiApocalyptic to suit my needs. Was wondering how I can get that info into a table using the Drop Down?Thanks Much in Advance. Link to comment https://forums.phpfreaks.com/topic/10077-drop-down-menu/#findComment-39594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.