Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/61035-complicated-user-management-script/
Share on other sites

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?

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>";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.