Welcome Guest, Not a member yet? Register   Sign In
Recursive funciton in Codeigniter
#1

[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


Messages In This Thread
Recursive funciton in Codeigniter - by El Forum - 09-12-2012, 03:52 AM
Recursive funciton in Codeigniter - by El Forum - 09-12-2012, 05:39 AM
Recursive funciton in Codeigniter - by El Forum - 09-12-2012, 09:04 PM
Recursive funciton in Codeigniter - by El Forum - 09-13-2012, 12:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB