stelthius Posted December 14, 2008 Share Posted December 14, 2008 Hello guys, Im just wondering how would one go about adding all the users in the database into a drop down menu, the reason for this is i have a ban user function but instead of trying to remember the name you cab just click the drop down menu and select the name to ban, Rick Quote Link to comment Share on other sites More sharing options...
T Horton Posted December 14, 2008 Share Posted December 14, 2008 Hi I think something like this would do it: <select name="ID"> <?php $query = "QUERY HERE"; $rs = mysql_query($query); while ($row = mysql_fetch_array($rs)) { echo "<option value='$row[0]'>$row[1]</option>"; } ?> </select> Hope this helps Tom Quote Link to comment Share on other sites More sharing options...
stelthius Posted December 14, 2008 Author Share Posted December 14, 2008 Hello again, Im not quite sure were im going wrnog but i tried this <? include("include/session.php"); ?> <select name="ID"> <?php $query = "SELECT * FROM `users` WHERE 1 = `username`"; $rs = mysql_query($query); while ($row = mysql_fetch_array($rs)) { echo "<option value='$row[0]'>$row[1]</option>"; } ?> </select> And it doesnt seem to be working, the other methods i have tried just show the md5 passwords lol im new to it so im not exactly sure what else to try with it Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 14, 2008 Share Posted December 14, 2008 Try this if you want username displayed on drop down and id as value posted: <? include("include/session.php"); ?> <select name="ID"> <?php $query = "SELECT id,username FROM users"; $rs = mysql_query($query); while ($row = mysql_fetch_assoc($rs)) { echo "<option value='",$row['id'],"'>",$row['username'],"</option>"; } ?> </select> Quote Link to comment Share on other sites More sharing options...
stelthius Posted December 14, 2008 Author Share Posted December 14, 2008 Ahhh! all so simple, thanks mate its appretiated. Quote Link to comment 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.