[eluser]foysal[/eluser]
I have table named 'users', where columns are like user_id, parent_user_id etc. That means every user has a parent user. I would like to view user like below
user1(parent user of user2)
-user2(parent user of user3)
--user3(parent user of user4)
---user4
user5(parent user of user)
-user6
I am trying to do this using the following function of a model with recursive function.
Code:
public function user_list($user_id)
{
$user_array = array();
$query = $this->db->get_where('users',array('user_parent_user_id'=>$user_id,'user_type'=>3,'user_status'=>1));
$results = $query->result();
if(empty($results))
{
return $results;
}
else
{
$user_array[] = $results[0]->user_id;
$this->user_list($results[0]->user_id);
}
return $user_array;
}
Could any one help me in this regard ??
Thanks
Foysal