<?php include("auth.php");?>
<?php include("header.php");?>

        <div class="content-body">
            <!-- row -->
			<div class="container-fluid">
            <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Top Investors</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-responsive-md">
                                        <thead>
                                            <tr>
                                              >
                                                <th><strong>Fullname</strong></th>
                                                <th><strong>Investment</strong></th>
                                                <th><strong>Profit</strong></th>
                                                <th><strong>Date</strong></th>
                                                <th></th>
                                            </tr>
                                        </thead>
                                        <tbody>


                                        <?php
include("dbcon.php");
$email = $_SESSION["email"];
if (isset($_GET['page_no']) && $_GET['page_no']!="") {
    $page_no = $_GET['page_no'];
    } else {
        $page_no = 1;
        }
	$total_records_per_page = 10;
		
$offset = ($page_no-1) * $total_records_per_page;
$previous_page = $page_no - 1;
$next_page = $page_no + 1;
$adjacents = "2";

$result_count = mysqli_query(
$db,
"SELECT COUNT(*) As total_records FROM user"
);
$total_records = mysqli_fetch_array($result_count);
$total_records = $total_records['total_records'];
$total_no_of_pages = ceil($total_records / $total_records_per_page);
$second_last = $total_no_of_pages - 1; // total pages minus 

$result = mysqli_query($db,"SELECT * FROM user ORDER BY lastdeposit DESC LIMIT $offset, $total_records_per_page");
while($row = mysqli_fetch_array($result)){

 
    
?>		
                                            <tr>
                                              
                                                <td><?php echo $row["firstname"]."".$row["lastname"];?></td>
                                                <td><?php echo '$'.number_format($row["lastdeposit"]);?></td>
                                                <td><?php echo $row["currentbalance"];?></td>
                                                
                                                <td><?php echo $row["maindate"];?></td>
                                                
                                            </tr>
											<?php
}
?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>   

                    <div style='padding: 10px 20px 0px; border-top: dotted 1px #CCC;'>
<strong>Page <?php echo $page_no." of ".$total_no_of_pages; ?></strong>
</div>
          
         
         <ul class="pagination">
<?php if($page_no > 1){
echo "<li><a href='?page_no=1'>First Page</a></li>";
} ?>

<li <?php if($page_no <= 1){ echo "class='disabled'"; } ?>>
<a <?php if($page_no > 1){
echo "href='?page_no=$previous_page'";
} ?>>Previous</a>
</li>

<li <?php if($page_no >= $total_no_of_pages){
echo "class='disabled'";
} ?>>
<a <?php if($page_no < $total_no_of_pages) {
echo "href='?page_no=$next_page'";
} ?>>Next</a>
</li>

<?php if($page_no < $total_no_of_pages){
echo "<li><a href='?page_no=$total_no_of_pages'>Last &rsaquo;&rsaquo;</a></li>";
} ?>
</ul>
     </div>
 </div>

        
</div>
</div>
<?php include("footer.php");?>