1. inc-db.php
2. paging.php
<?php
include('../inc-db.php');
error_reporting(0);
$batas=5;
//$posisi=0;
$halaman=$_GET['halaman'];
if(empty($halaman)){
$posisi=0;
$halaman=1;
}else {
$posisi=($halaman - 1) * $batas;
}
$sqlShow="SELECT * FROM tb_mahasiswa LIMIT ".$posisi.",".$batas;
$result=mysql_query($sqlShow);
?>
<table border='1'>
<tr><td><b>No</b></td><td><b>Nim</b></td><td><b>Nama</b></td><td><b>Alamat</b></td></tr>
<?php
$no=$posisi+0;
while($data=mysql_fetch_array($result)){
$no++;
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $data['nim']; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['alamat']; ?></td>
</tr>
<?php
}
?>
</table>
<?php
$sqlCout="SELECT * FROM tb_mahasiswa";
$result1=mysql_query($sqlCout);
$result_count=mysql_num_rows($result1);
//echo "<b>".$result_count."</b><br>";
$jumlah_halaman=ceil($result_count/$batas);
//echo $jumlah_halaman."<br>";
echo "Halaman : ";
for($i=1;$i<=$jumlah_halaman;$i++)
if($i != $halaman){
echo "<a href='$PHP_SELF?halaman=$i'>".$i." </a>|";
} else {
echo"<b>".$i."</b> | ";
}
?>
2. paging.php
<?php
include('../inc-db.php');
error_reporting(0);
$batas=5;
//$posisi=0;
$halaman=$_GET['halaman'];
if(empty($halaman)){
$posisi=0;
$halaman=1;
}else {
$posisi=($halaman - 1) * $batas;
}
$sqlShow="SELECT * FROM tb_mahasiswa LIMIT ".$posisi.",".$batas;
$result=mysql_query($sqlShow);
?>
<table border='1'>
<tr><td><b>No</b></td><td><b>Nim</b></td><td><b>Nama</b></td><td><b>Alamat</b></td></tr>
<?php
$no=$posisi+0;
while($data=mysql_fetch_array($result)){
$no++;
?>
<tr>
<td><?php echo $no; ?></td>
<td><?php echo $data['nim']; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['alamat']; ?></td>
</tr>
<?php
}
?>
</table>
<?php
$sqlCout="SELECT * FROM tb_mahasiswa";
$result1=mysql_query($sqlCout);
$result_count=mysql_num_rows($result1);
//echo "<b>".$result_count."</b><br>";
$jumlah_halaman=ceil($result_count/$batas);
//echo $jumlah_halaman."<br>";
echo "Halaman : ";
for($i=1;$i<=$jumlah_halaman;$i++)
if($i != $halaman){
echo "<a href='$PHP_SELF?halaman=$i'>".$i." </a>|";
} else {
echo"<b>".$i."</b> | ";
}
?>
Tidak ada komentar:
Posting Komentar