<?php

// koneksi ke database
include "connect.php";
$hasil2 = mysqli_query($koneksi,"SELECT * FROM tset where idset=1");
$data2 = mysqli_fetch_array($hasil2);
$status="AKTIF";


$hasil = mysqli_query($koneksi,"SELECT * FROM mhs where tingkat=$data2[tk] AND status='$status'");
$total = mysqli_num_rows($hasil);//dapatkan jumlah semua data

//paging

	$entries=10; //nilai awal==jumlah data yang ditampilkan setiap halaman
	
	//************awal paging************//
	
	if ($total>$entries)  //jika jumlah semua data lebih banyak dari nilai awal yang diberikan
	{
		echo " <form action='userbaak.php' methode='post'> <button type='submit'>Home</button><button onclick='window.print()'>Print</button> Halaman : ";
		$pages=1;
		while($pages<=ceil($total/$entries))
		{
			if ($pages!=1)
			{
				echo " | ";
			}
		?>
		<!--Membuat link sesuai nama halaman-->
		<a href="cetakkartu.php?id=<? echo ($pages-1); ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><? echo $pages; ?></font></a>
 
		 <?
				$pages++;
		}
	}else{
		$pages=0;
	}
	
	//**************akhir paging*****************//
	
	?>
	</form>
	  </font>
	<?
	$page=(int)$_GET['id'];
	$offset=$page*$entries;
	
	//menampilkan data dengan menggunakan limit sesuai parameter paging yang diberikan
	$hasil3=mysqli_query($koneksi,"select * from mhs where tingkat=$data2[tk] AND status='$status' order by nim asc limit $offset,$entries");
	//$total3 = mysqli_num_rows($hasil3);


// setting banyaknya kolom
$kolom = 2;

echo "<table border='1'>";

$counter = 1;
while ($data = mysqli_fetch_array($hasil3))
{
	if (($counter-1) % $kolom == 0) echo "<tr>";
		echo "<td align='center' style='padding: 5px' width='300'><font size='4' color='#0000CC'><strong>KARTU ".$data2['kartu']."</strong></font></br>
		<font size='3' color='#0000CC'>AKADEMI KEPERAWATAN RS EFARINA</font><hr>
		<img src='picture/icon.png' width='30' height='30' border='0'></br><font size='4'>".$data['nm_mhs']."</font><br />".$data['nim'].
		"<br /><hr> <font size='-1'>".$data['prog_study']."/TK.".$data['tingkat']."/SMT.".$data['semester']."/TA.".$data2['ta']."</font></td>";
	if ($counter % $kolom == 0) echo "</tr>";
	$counter++;
}
echo "</table>";
?>
