[eluser]Unknown[/eluser]
[quote author="boltsabre" date="1361873710"]Sure, make sure you cleanse your DB variable (userdata('group')) first incase someone has hacked your session, or better use active records which will automatically cleanse your query for your, then when you echo it out do this:
Code:
foreach ($query->result() as $row)
{
echo "<li><a href='".base_url()."admin/view_user/".$row->username . "'>".$row->username."</a></li>";
}
This will create your hyperlinks. You could echo this a little different and make use of the CI function anchor(), but you get the idea!
And then you in your "admin" controller, you would have a function called "view_user", which would access a "variable" called "$username, like this:
Code:
class Admin extends CI_Controller{
... // constructor goes here if you have one
function view_user($username = null){
if($username == null){
echo "No username was passed to me"; //do whatever you want to do here
}
//else we have a username, now you can do whatever you want.
//more then likely you'll want to load your model if you haven't already, and then call a funtion that
//gets the user details by their username. Make sure it is unique!
}
}
[/quote]
Thanks for that, boltsabre.
Is any additional routing required? I have implemented your suggestions as below;
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends CI_Controller{
// constructor goes here if you have one
function view_user($username = null){
if($username == null){
echo "No username was passed to me"; //do whatever you want to do here
}
$data['title']= 'User Administration';
$this->load->view('header_view',$data);
$this->load->view('user_view.php', $data);
$this->load->view('footer_view',$data);
}
}
?>
However the links are still returning 404