<!doctype html>
<html lang="en">
<?php
  include_once("../../element/connection.php");
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type"content="text/html; charset=utf-8"/>
		<meta name="viewport"content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
		<title>Binary Tree Structure</title>
		<link href="css/style.css"rel="stylesheet"type="text/css"/>
         <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>NCr Marketing - Your Panel</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link href="../assets/img/favicon.png" rel="icon">
  <link href="../assets/img/apple-touch-icon.png" rel="apple-touch-icon">

  <!-- Google Fonts -->
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="../assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="../assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link href="../assets/vendor/quill/quill.bubble.css" rel="stylesheet">
  <link href="../assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="../assets/vendor/simple-datatables/style.css" rel="stylesheet">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css">
    <link href="../assets/vendor/fonts/circular-std/style.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/libs/css/style.css">
    <link rel="stylesheet" href="../assets/vendor/fonts/fontawesome/css/fontawesome-all.css">
    <link rel="stylesheet" href="../assets/vendor/charts/morris-bundle/morris.css">
    <link rel="stylesheet" href="../assets/vendor/fonts/material-design-iconic-font/css/materialdesignicons.min.css">

  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script>
	</head>
	<body>
        
        
        <div class="col-lg-8 col-sm-12 card bg-light p-0">
              <h5 class="card-header">Tree View</h5>
                
                
                
             
            <div class="card-body">



             
                  <div class="row p-3">
                    <?php
                        for ($d=0; $d < $divide ; $d++) {
                          ?>
                            <div class="col-<?php echo 12/$divide ?>  p-3 text-center">
                                <img src="<?php echo ($id[$d]!=0)?"download.png":"download2.png" ?>" class="img-fluid" alt="" style="width:50px"><br>
                                <p id="<?php echo $id[$d] ?>"  onclick=<?php echo ($id[$d]!=0)?"show_details(this)":"" ?>><?php echo $print_id=$id[$d] ?></p>
                            </div>
                          <?php
                          for ($p=0; $p < 2 ; $p++) {
                            $temp_id[$temp_id_index]=fetch_left_right($p,$print_id);
                            $temp_id_index++;
                          }
                        }
                        $id=$temp_id;
                     ?>
                  </div>
                  <?php
                }


                function fetch_left_right($side,$agent_id){
                  global $conn;
                  if ($side==0) {
                    $pos='left_side';
                  } else {
                    $pos='right_side';
                  }
                  $data=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `users` WHERE `user_id`='$agent_id'"));
                  if ($agent_id!=0) {
                    return $data[$pos];
                  } else {
                    return 0;
                  }

                }
               ?>



            </div>
           
           </div>
        
        
        
		<div class="container">
			<div class="row">
				<div class="tree">
					<ul>
						<li> <a href="#"><img src="images/1.jpg"><span>Child</span></a>
						<ul>
							<li><a href="#"><img src="images/2.jpg"><span>Grand Child</span></a>
							<ul>
								<li> <a href="#"><img src="images/3.jpg"><span>Great Grand Child</span></a> </li>
								<li> <a href="#"><img src="images/4.jpg"><span>Great Grand Child</span></a> </li>
							</ul>
						</li>
						<li> <a href="#"><img src="images/5.jpg"><span>Grand Child</span></a>
						<ul>
							<li> <a href="#"><img src="images/6.jpg"><span>Great Grand Child</span></a> </li>
							<li> <a href="#"><img src="images/7.jpg"><span>Great Grand Child</span></a> </li>
							<li> <a href="#"><img src="images/8.jpg"><span>Great Grand Child</span></a> </li>
						</ul>
					</li>
					<li><a href="#"><img src="images/9.jpg"><span>Grand Child</span></a></li>
				</ul>
			</li>
		</ul>
	</div>
</div>
</div>
</body>
</html>