Belajar PHP Belajar PHP | Page 31
$halaman=1;
}
else
{
$posisi = ($halaman-1) * $batas;
}
$tampil="select * from tamu ORDER BY no_tamu DESC limit $posisi,$batas";
$hasil=mysql_query($tampil);
while ($data=mysql_fetch_array($hasil)){
echo "
$data[nama] |
$data[email] |
$data[pesan] |
";
}
echo "
";
$file="form_tamu.php";
$tampil2="select * from tamu";
$hasil2=mysql_query($tampil2);
$jmldata=mysql_num_rows($hasil2);
$jmlhalaman=ceil($jmldata/$batas);
//link ke halaman sebelumnya (previous)
if($halaman > 1)
{
$previous=$halaman-1;
echo "<< First |
< Previous | ";
}
else
{
echo "<< First | < Previous | ";
}
$angka=($halaman > 3 ? " ... " : " ");
for($i=$halaman-2;$i<$halaman;$i++)
{
if ($i < 1)
continue;
$angka .= "$i ";
}
$angka .= " $halaman ";
for($i=$halaman+1;$i<($halaman+3);$i++)
{
if ($i > $jmlhalaman)
break;
$angka .= "$i ";
}
$angka .= ($halaman+2<$jmlhalaman ? " ...
$jmlhalaman " : " ");