  <?php
	include_once('../config.php');   
    
  
          
    if(!isset($_SESSION['userid']))
    { 
         header("Location: ../");
         die;
    }

                        $ky=0;
                        $Ary = array();
                        function Gre_left($val)
                        {   
                                global $conn; 
                                global $Ary;
                                global $ky;
                                $stmt=$conn->prepare("select  `left`  from tree  where userid =:refId ");   
                                $stmt->bindValue(':refId', $val , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                $Result = $stmt->fetch(PDO::FETCH_OBJ);  
                                
                                $stmt=$conn->prepare("select  nm,RegOn from user  where cuurentId =:cuurentId ");   
                                $stmt->bindValue(':cuurentId', $val , PDO::PARAM_INT);  
                                $stmt->execute(); 
                                $name = $stmt->fetch(PDO::FETCH_OBJ); 
                                
                                $Ary[$ky]['left'] = $Result->left;
                                $Ary[$ky]['RegOn'] = $name->RegOn;
                                $Ary[$ky]['nm'] = $name->nm;    
                                  
                                if($Result->left!='') 
                                {
                                    $ky++;
                                    Gre_left($Result->left); 
                                }      
                        }    
                        Gre_left($_SESSION['userid']);    
                         
include_once("../view/dashboard/leftree.php");
?>