Irksome Posted July 20, 2007 Share Posted July 20, 2007 Hi all, I have a rather complicated issue here and can't seem to resolve it even after a full hour of working at it. I have an admin section on my site, and under the user management section I made it present a basic list of users with a link next to each username to edit thier profiles. Now, what I want is a listbox, with all of the usernames in it, and a button next to it to edit the selected user's profile. The code for my current page is below: <?php include("../db.php"); //load all users from the database and then ORDER them by userid $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connect); //Make loop and get all users from the database while($myrow = mysql_fetch_assoc($result)) {//begin of loop //Results echo $myrow['username']; // Link to edit user echo "<br><a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>"; }//end of loop ?> How can I convert this to a listbox with a button next to it leading to "edit_user.php"? Any help would be very much appreciated. Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 Erm.. using a form drop down box with the vaules as $myrow[userid]'s and a submit button.. have the action point to edit_user.php.. thats the idea but i am not writing it for you as its kinda basic and this is a learning site! Quote Link to comment Share on other sites More sharing options...
Irksome Posted July 21, 2007 Author Share Posted July 21, 2007 Hi, yes I've tried that many times over, but all I get is parse errors. The one time I did get an actual result, it brought up a seperate box for each username. I want them all in one box. I guess I'm doing something wrong like missing out quotes or semicolons somewhere. Here is the code I have: <?php session_start(); require "../db.php"; require "../global.php"; switch ($_SESSION['user_level']) { default:echo $text['adminperms']; exit; case 4: case 5: $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connection)or die(mysql_error()); while($myrow = mysql_fetch_assoc($result)) echo "<form action=\"edit_user.php?userid=$myrow[userid]\" method=get><select name=select size=10> <option>"; { echo $myrow['username']; } echo "</option></select> <input type=submit name=Submit value=Submit></form>"; // Now print the options } echo '<br>'; ?> Can anyone see what's wrong here? Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Share Posted July 21, 2007 I was able to get all of mine to show in a single box using this type of code: $result = @mysql_query($sql, $connection) or die(mysql_error()); $contact_list = "<ul>"; while ($row = mysql_fetch_array($result)) { $id = $row['id']; // Change to whatever criteria you need $lname = $row['lname']; // Change to whatever criteria you need $fname = $row['fname']; // Change to whatever criteria you need $contact_list .= "<li><a href=\"show_contact.php?id=$id\">$lname, $fname</a>"; // This row will populate your list based on the same criteria you specified above. } $contact_list .= "</ul>"; ?> 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.