$dataPerPage= 20 ;
if(isset($_GET['page'])){
$noPage = $_GET['page'];}
else
$noPage = 1;
$offset=($noPage - 1)* $dataPerPage;
$where = '';
If(isset($_POST['search'])){
$tgl_awal= $_POST['tgl_awal'];
$tgl_akhir= $_POST['tgl_akhir'];
$sort = $_POST['ord'];
$nama = $_POST['keyw'];
$where .= " WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND nama LIKE '%$nama%' ORDER BY log_absen $sort LIMIT $offset, $dataPerPage";
$query = "SELECT * FROM absen" .$where;
$result = mysql_query($query) or die(mysql_error());}
elseif (isset($_POST['searchall'])){
$query = "SELECT * FROM absen ORDER BY log_absen DESC LIMIT $offset, $dataPerPage";
$result = mysql_query($query) or die(mysql_error());}
else {
$where .= " WHERE tanggal = CURDATE() ORDER BY log_absen DESC LIMIT $offset, $dataPerPage";
$query = "SELECT * FROM absen" .$where;
$result = mysql_query($query) or die(mysql_error());}
/*$isiabsen= mysql_query("SELECT * FROM absen ORDER BY log_absen DESC");*/
echo "<h1>Hasil pencarian</h1>";
echo "<table align='center' border='1' cellpadding='5' cellspacing='0' align='center'>
<tr>";
echo "<th><font size='2' face='Arial'>Log</font></th>";
echo "<th><font size='2' face='Arial'>Name</font></th>";
echo "<th><font size='2' face='Arial'>Location</font></th>";
echo "<th><font size='2' face='Arial'>Date</font></th>";
echo "<th><font size='2' face='Arial'>Time</font></th>";
echo "</tr>";
while($row1= mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><font size='2' face='Arial'>" . $row1['log_absen'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['nama'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['lokasi'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['tanggal'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['waktu'] . "</font></td>";
echo "</tr>";}
echo "</table>";
$qp="SELECT Count(*)AS jumData FROM absen" .$where;
$hasil= mysql_query($qp);
$data = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
if($noPage>1)
echo "<font align='center' size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'><< Prev</a></font>";
for($page = 1; $page <=$jumPage; $page++){
if((($page>=$noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage)){
$showPage = $page;
if(($showPage == 1) && ($page !=2)) echo " ";
if(($showPage !=($jumPage - 1))&&($page==$jumPage)) echo " ";
if ($page == $noPage) echo"<font align='center' size='2' face='Arial'>".$page."</font>";
else echo"<font align='center' size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a></font>";
$showPage = $page;
}
}
if ($noPage < $jumPage){
echo "<font size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'> Next >></a></font>";}
?>
$dataPerPage= 20 ;
if(isset($_GET['page'])){
$noPage = $_GET['page'];}
else
$noPage = 1;
$offset=($noPage - 1)* $dataPerPage;
$where = '';
If(isset($_GET['search'])){
$tgl_awal= $_GET['tgl_awal'];
$tgl_akhir= $_GET['tgl_akhir'];
$sort = $_GET['ord'];
$nama = $_GET['keyw'];
$where .= " WHERE tanggal BETWEEN '$tgl_awal' AND '$tgl_akhir' AND nama LIKE '%$nama%' ORDER BY log_absen $sort LIMIT $offset, $dataPerPage";
$query = "SELECT * FROM absen" .$where;
$result = mysql_query($query) or die(mysql_error());}
elseif (isset($_POST['searchall'])){
$query = "SELECT * FROM absen ORDER BY log_absen DESC LIMIT $offset, $dataPerPage";
$result = mysql_query($query) or die(mysql_error());}
else {
$where .= " WHERE tanggal = CURDATE() ORDER BY log_absen DESC LIMIT $offset, $dataPerPage";
$query = "SELECT * FROM absen" .$where;
$result = mysql_query($query) or die(mysql_error());}
/*$isiabsen= mysql_query("SELECT * FROM absen ORDER BY log_absen DESC");*/
echo "<h1>Hasil pencarian</h1>";
echo "<table align='center' border='1' cellpadding='5' cellspacing='0' align='center'>
<tr>";
echo "<th><font size='2' face='Arial'>Log</font></th>";
echo "<th><font size='2' face='Arial'>Name</font></th>";
echo "<th><font size='2' face='Arial'>Location</font></th>";
echo "<th><font size='2' face='Arial'>Date</font></th>";
echo "<th><font size='2' face='Arial'>Time</font></th>";
echo "</tr>";
while($row1= mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><font size='2' face='Arial'>" . $row1['log_absen'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['nama'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['lokasi'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['tanggal'] . "</font></td>";
echo "<td><font size='2' face='Arial'>" . $row1['waktu'] . "</font></td>";
echo "</tr>";}
echo "</table>";
$qp="SELECT Count(*)AS jumData FROM absen" .$where;
$hasil= mysql_query($qp);
$data = mysql_fetch_array($hasil);
$jumData = $data['jumData'];
$jumPage = ceil($jumData/$dataPerPage);
//bentuk url paramater menggunakan informasi dari $_GET
$params = $_GET;
unset($params['page']);
$urlParam = $params ? '&'.http_build_query($params) : '';
if($noPage>1)
echo "<font align='center' size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1).$urlParam."'><< Prev</a></font>";
for($page = 1; $page <=$jumPage; $page++){
if((($page>=$noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage)){
$showPage = $page;
if(($showPage == 1) && ($page !=2)) echo " ";
if(($showPage !=($jumPage - 1))&&($page==$jumPage)) echo " ";
if ($page == $noPage) echo"<font align='center' size='2' face='Arial'>".$page."</font>";
else echo"<font align='center' size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".$page.$urlParam."'>".$page."</a></font>";
$showPage = $page;
}
}
if ($noPage < $jumPage){
echo "<font size='2' face='Arial'><a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1).$urlParam."'> Next >></a></font>";}
?>
dan ingat ubah method form dari method="post" menjadi method="get"