title: recursive function call in binary tree
body: <p>i have a table ft_individual which store information about a binary tree it comprises of attributes Id,User_name,Active(to represent user is active or not ),Position(L for left, R for right),and Father_id....
  i want to get the number of child’s in left position of a particular user then the number of child’s in left position of a user.</p>
  
  <p>i made a recursive function call but it is not working.
  I am using PHP codeigniter frame work......Help</p>
  
  <pre><code>$l_count=$this-&gt;tree_model-&gt;childCount($user_i,'L');
  
  $r_count=$this-&gt;tree_model-&gt;childCount($user_i,'R');
  </code></pre>
  
  <p>inside model.</p>
  
  <pre><code>public function childCount($user_id='',$position='')
      {     
              $this-&gt;db-&gt;select('id');
              $this-&gt;db-&gt;from('ft_individual');
              $this-&gt;db-&gt;where('father_id',$user_id);
              $this-&gt;db-&gt;where('position',$position);
              $this-&gt;db-&gt;where('active','yes');
              $result=$this-&gt;db-&gt;get();
              foreach ($result-&gt;result() as $row)
              {
                 $id= $row-&gt;id;
              }  
              if($id!='')
              {   
                  return (1+childCount($id,'L')+childCount($id,'R')); 
              }
             else
              {   
                  return 1; 
              }   
      }
  </code></pre>