<!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=iso-8859-1" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title>:: Daftar Calon Siswa - SMAT Krida Nusantara</title>
<style type="text/css">
  	.hoverTable{
		width:100%; 
		border-collapse:collapse; 
	}
	.hoverTable td{ 
		padding:1px; border:#4e95f4 1px solid;
	}	
    /* Define the default color for all the table rows */
    .hoverTable tr{
        background: #ffffff;
    }
    /* Define the hover highlight color for the table row */
    .hoverTable tr:hover {
          background-color: #86D694;
    }
    .hoverTable tr:first-child {
        background: #a9c8ef;
    }
	.style1 {font-size: 14px; font-weight: bold; font-family: "Bookman Old Style"; }
	.style2 {font-size: 12px; font-weight: bold; font-family: Arial, Helvetica, sans-serif; }
	.style3 {font-size: 12px; font-weight: normal; font-family: Arial, Helvetica, sans-serif; }
</style>
</head>

<body background="../image/back.gif">

<table class="hoverTable" width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="light blue" bordercolor="#f1f1f1">
	<tr bgcolor="#b2c6e7">
		<td width="5%" background="../image/submenu.gif"><div align="center" class="style2"><Strong><b>No.</b></Strong></div></td>
		<td width="20%" background="../image/submenu.gif"><div align="center" class="style2"><Strong><b>No.Registrasi</b></Strong></div></td>
		<td width="30%" background="../image/submenu.gif"><div align="center" class="style2"><Strong><b>Nama Calon Siswa</b></Strong></div></td>
		<td width="35%" background="../image/submenu.gif"><div align="center" class="style2"><Strong><b>Status</b></Strong></div></td>
    </tr>
<!-- </table> -->
<?php
    ini_set("display_errors","off");

    error_reporting(0);
	$results_per_page = 50;
	$datatable = "peserta";
	
	$db = mysqli_connect("localhost","kridanus_peserta","d4ft4rp3s3rt4_nyA","kridanus_pesertappdb");
    if (!$db) {
		die("Connection failed: " . mysqli_connect_error());
	}
	
	$query = "SELECT * FROM $datatable";
    $result = mysqli_query($query, $db);
    $num_record = mysqli_num_rows($result);
    
	if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
	$start_from = ($page-1) * $results_per_page;
	$sql = "SELECT * FROM ".$datatable." ORDER BY NOTEST ASC LIMIT $start_from, ".$results_per_page;
	$rs_result = $db->query($sql); 

// echo "<table class='hoverTable' width='100%' border='1' cellspacing='0' cellpadding='0' bgcolor='#' bordercolor='#f1f1f1'>";	
	while($row = $rs_result->fetch_assoc()) {

    {
    	$jhavs=$jhavs+1;
/*
	if ($colorcounter == 0) 
        {
    		$colorbg = "#dbe9f4";
    	}
    	else 
	{
    		$colorbg = "#ffffff";
    		$colorcounter = $colorcounter - 2;
    	}
*/		
	$nourut = $jhavs + (($page-1)*$results_per_page);	
	echo "<Tr>";
	echo "<Td bgcolor=$colorbg><div align=center class=style3>$nourut</div></Td>";
	echo "<Td bgcolor=$colorbg><div align=left class=style3>$row[noreg]</div></Td>";
	echo "<Td bgcolor=$colorbg><div align=left class=style3>$row[namap]</div></Td>";
	echo "<Td bgcolor=$colorbg><div align=center class=style3>Sudah Terverifikasi</div></Td>";
	echo "</Tr>";
//    	$colorcounter = $colorcounter + 1;
    };
 }; 	
echo "</table>";
    
$sql = "SELECT COUNT(NO_ID) AS total FROM ".$datatable;
$result = $db->query($sql);
$row = $result->fetch_assoc();
//$num_record = mysqli_num_rows($result);
$total_pages = ceil($row["total"] / $results_per_page); // calculate total pages with results
  
//echo "Total '$jhavs' Record ";
//echo "Total '$num_record' Record : ";

for ($i=1; $i<=$total_pages; $i++) {  // print links for all pages
            echo "<a href='daftarpeserta.php?page=".$i."'";
            if ($i==$page)  echo " class='curPage'";
            echo ">".$i."</a> "; 
}; 
    
?>