Advertisement
Guest User

Untitled

a guest
Jul 30th, 2012
603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. // Get Geneology Tree
  2. function get_geneology_tree($parent_id=0, $output=""){
  3.     if(empty($parent_id))
  4.         $sql="SELECT *, CONCAT(title,' ',first_name,' ',middle_name,' ',last_name) as full_name
  5.                 FROM mlm_user_mst
  6.                 WHERE parent_id='$parent_id'
  7.                   AND user_type<>'Admin'";
  8.     else
  9.         $sql="SELECT *, CONCAT(title,' ',first_name,' ',middle_name,' ',last_name) as full_name
  10.                 FROM mlm_user_mst
  11.                 WHERE mlm_user_id_pk='$parent_id'
  12.                   AND user_type<>'Admin'";
  13.  
  14.     $result=mysql_query($sql)or die(mysql_error());
  15.     $num_rows=mysql_num_rows($result);
  16.  
  17.     if(!empty($num_rows)){
  18.  
  19.         $output='<ul'.((empty($output))?' id="org"':'').'>';
  20.  
  21.         $arrres=mysql_fetch_assoc($result);
  22.  
  23.         $output.='<li>'.$arrres['full_name'];
  24.  
  25.         if(!empty($arrres['left_id'])){
  26.             $output.=get_geneology_tree($arrres['left_id'], $output);
  27.         }
  28.  
  29.         if(!empty($arrres['right_id'])){
  30.             $output.=get_geneology_tree($arrres['right_id'], $output);
  31.         }
  32.  
  33.         $output.='</li>';
  34.  
  35.         $output.='</ul>';
  36.     }
  37.    
  38.     return $output;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement