<html>
<head>
<title>LIST MHS</title>
</head>
<body>
<h3><center> DAFTAR MAHASISWA</h3>
<p align="center"><font face="verdana" size="2">
<?
	include "connect.php"; //include file koneksi
	$entries=3; //nilai awal==jumlah data yang ditampilkan setiap halaman
	
	//************awal paging************//
	$tampil="select * from mhs"; //input
	$hasil=mysql_query($tampil);
	$total = mysql_num_rows($hasil);//dapatkan jumlah semua data
	
	if ($total>$entries)  //jika jumlah semua data lebih banyak dari nilai awal yang diberikan
	{
		echo "Halaman : ";
		$pages=1;
		while($pages<=ceil($total/$entries))
		{
			if ($pages!=1)
			{
				echo " | ";
			}
		?>
		<!--Membuat link sesuai nama halaman-->
		<a href="tampilmhs.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*****************//
	
	?>
	  </font>
	<?
	$page=(int)$_GET['id'];
	$offset=$page*$entries;
	
	//menampilkan data dengan menggunakan limit sesuai parameter paging yang diberikan
	$tampil2="select * from mhs order by nim desc limit $offset,$entries";
	$hasil2=mysql_query($tampil2);
	$total2 = mysql_num_rows($hasil2);
?>
</p>
<table align="center" width="1197" border="0">
			<tr align="center" bgcolor='#6699FF'>
				<th width="114"><font face="verdana" size="2" color="#FFFFFF">NIM</font></th>
				<th width="180"><font face="verdana" size="2" color="#FFFFFF">Nama</font></th>
				<th width="180"><font face="verdana" size="2" color="#FFFFFF">Tingkat</font></th>
				<th width="180"><font face="verdana" size="2" color="#FFFFFF">Kelas</font></th>
				<th width="180"><font face="verdana" size="2" color="#FFFFFF">Semester</font></th>
				<th width="142"><font face="verdana" size="2" color="#FFFFFF">Prodi</font></th>
				<th width="232"><font face="verdana" size="2" color="#FFFFFF">Aksi</font></th>
			</tr>
	<?
	if ($total2){
		while ($row=mysql_fetch_array($hasil2))
		{
		?>
			<tr bgcolor="#D5E9FF">
				<td valign="top"><font face="verdana" size="2"><? echo $row[0]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><a href="viewmhs.php?id=<? echo $row[0]; ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><? echo $row[1]; ?></font></a></td>
			    <td valign="top"><font face="verdana" size="2"><? echo $row[2]; ?></font></td>
			    <td valign="top"><font face="verdana" size="2"><? echo $row[3]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><? echo $row[4]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><? echo $row[12]; ?></font></td>
				<td valign="top" align="center"><font face="verdana" size="2"><a href=formeditmhs.php?id=<? echo $row[0]; ?>>Edit</a> |
																<a href=cetakktu.php?id=<? echo $row[0]; ?>>Print</a> | 
																<a href=fmhs.php?id=<? echo $row[0]; ?>>Trans</a> |
																<a href=hapusmhs.php?id=<? echo $row[0]; ?> onClick="return confirm('Yakin data ini akan dihapus...?')">Hapus</a></font></td>
		<?	
		} 
	}else{
		?><p align="center"><font color="#FF0000" face="verdana" size="2"><b>Belum ada data!!</b></font></p><?
	}
	?>
		<tr bgcolor="#D5E9FF">
		<td colspan="8" align="center"><font face="verdana" size="2">JUMLAH: <? echo $total; ?></font></td></tr>
		<tr><td colspan="8" align="right"><font face="verdana" size="2"><a href=fmhs.php>Input Mhs</font></a></td></tr>
</table>
</body>
</html>
