<?php
session_start();
require_once('includes/init.php');

if(!empty($_GET['cp']) && !empty($_GET['cge'])) {
    $_SESSION['cp'] = $_GET['cp'];
    $_SESSION['cge'] = $_GET['cge'];
}

if($_GET['app'] == 'main') {
	$_SESSION['main_app'] = "1";
}

$_SESSION['token'] = $_COOKIE['token'] ?? null;

if ( !isset($_SESSION['token']) ) {
	header('location: login.php?' . http_build_query($_GET));
}

$token = $_SESSION['token'];

$user_data = get_user_by_token($conn, $token);
$refert = $user_data['mobile'];
if ( empty( $user_data ) ) header('location: login.php?' . http_build_query($_GET));


$string = file_get_contents("../This_is_Admin_/app-data.json");
$json_a = json_decode($string, true);

?>
<!DOCTYPE html>
<html>
<head>
	<title>Refer </title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=false">
	<link rel="stylesheet" href="css/style.css" >
	<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">
       
      
      
    <style>
		<?php include 'css/custom-style.php' ?>
   


		table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
th, td {
  padding: 5px;
  text-align: left;
}


.topbar { 
      background: <?= $bg_top ?> !important;
      padding: 10px;
      
}
.topbars { 
      background: <?= $bg_primary ?> !important;
      padding: 10px;
}



	</style>
</head>

  

		<body class="bg-white">  
<section class="topbars">
	  <i style="font-family: 'Material Icons'; font-size: 30px;"><br>escalator_warning</i><br>Refer List<br><br><br>
		</section>
			<section class="payments">
			<div style="overflow-x:auto">
				<table class="top-users-table">
 <?php    
$sql = "SELECT * FROM users WHERE ref = $refert";
if($result = mysqli_query($conn, $sql)){
    if(mysqli_num_rows($result) > 0){
				 echo "	<table id='customers' class='payments-table mytable'>";
				  echo "<tr class='topbars'>";
				 echo "<th>#</th>";
                echo "<th>Name</th>";
                echo "<th>Number</th>";
              
					echo "</tr>";
					
			while($row = mysqli_fetch_array($result)){
            echo "<tr class='row' style='color : black'>";
                echo "<td></td>";
                 echo "<td>" . $row['fname'] . "</td>";
                 
                 echo "<td>" . $row['mobile'] . "</td>";
    
            echo "</tr>";
            }
            
            
           
             
            
            
        echo "</table>";
        // Free result set
        mysqli_free_result($result);
    } else{
        echo "No records matching your query were found.";
    }
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
 
// Close connection
mysqli_close($conn);
?>
</center>
 </section></div></div>


</body>
</html><style>
 .mytable {
 counter-reset: serial-number; /* Set the serial number counter to 0 */
}
.mytable td:first-child:before {
 counter-increment: serial-number; /* Increment the serial number counter */
 content: counter(serial-number); /* Display the counter */
}</style>
		
		

		
		






