<html>
<head>
<title>LIST CMHS</title>
</head>
<body>
<h3><center> DAFTAR CALON MAHASISWA BARU </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 cmhs"; //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="tampilcmhs.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 cmhs order by no_cmhs 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'>
				<td width="114"><b><font face="verdana" size="2" color="#FFFFFF">No.Peserta</font></b></td>
				<td width="180"><b><font face="verdana" size="2" color="#FFFFFF">Nama</font></b></td>
				<td width="115"><b><font face="verdana" size="2" color="#FFFFFF">Tanggal Lahir</font></b></td>
				<td width="199"><b><font face="verdana" size="2" color="#FFFFFF">Asal Sekolah</font></b></td>
				<td width="142"><b><font face="verdana" size="2" color="#FFFFFF">Prodi</font></b></td>
				<td width="139"><b><font face="verdana" size="2" color="#FFFFFF">TA</font></b></td>
				<td width="42"><b><font face="verdana" size="2" color="#FFFFFF">Ket</font></b></td>
				<td width="232"><b><font face="verdana" size="2" color="#FFFFFF">Aksi</font></b></td>
			</tr>
	<?
	if ($total2){
		while ($row=mysql_fetch_array($hasil2))
		{
		?>
			<tr bgcolor="#D5E9FF">
				<td valign="top"><font face="verdana" size="2"><? echo $row[2]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><a href="viewcmhs.php?id=<? echo $row[0]; ?> " style="text-decoration:none"><font size="2" face="verdana" color="#009900"><? echo $row[3]; ?></font></a></td>
			    <td valign="top"><font face="verdana" size="2"><? echo $row[5]; ?></font></td>
			    <td valign="top"><font face="verdana" size="2"><? echo $row[12]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><? echo $row[15]; ?></font></td>
				<td valign="top"><font face="verdana" size="2"><? echo $row[17]; ?></font></td>
				<td valign="top" align="center"><font face="verdana" size="2"><? echo $row[18]; ?></font></td>
				<td valign="top" align="center"><font face="verdana" size="2"><a href=formeditcmhs.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=hapuscmhs.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>

</table>
</body>
</html>
