1. File CSS
/*pagination*/
#tnt_pagination {
margin-top:10px;
display:block;
text-align:left;
height:22px;
line-height:21px;
clear:both;
padding-top:3px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:normal;
}
#tnt_pagination a:link, #tnt_pagination a:visited{
padding:7px;
padding-top:2px;
padding-bottom:2px;
border:1px solid #ddd;
margin-left:5px;
text-decoration:none;
background-color:#eee;
color:#666;
width:22px;
font-weight:normal;
}
#tnt_pagination a:hover {
background-color:#EF652A;
border:1px solid #F30;
color:#fff;
}
#tnt_pagination .active_tnt_link {
padding:7px;
padding-top:2px;
padding-bottom:2px;
margin-left:5px;
text-decoration:none;
color:#fff;
cursor:default;
background-color:#EF652A;
border:1px solid #F30;}
#tnt_pagination .disabled_tnt_pagination {
padding:7px;
padding-top:2px;
padding-bottom:2px;
border:1px solid #EBEBEB;
margin-left:5px;
text-decoration:none;
background-color:#F5F5F5;
color:#D7D7D7;
cursor:default;
}
/* — end pagination—*/
2. File PHP
echo ‘
’;
$host = $_SERVER['HTTP_HOST'];
$self = $_SERVER['PHP_SELF'];
$query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$url = !empty($query) ? “http://$host$self?$query” : “http://$host$self”;
$url=str_replace(‘index.php’,”,$url);
$qpagination=”SELECT COUNT(id) AS jumData FROM produk”;
$rdata=mysql_fetch_array(mysql_query($qpagination));
$jumData = $rdata[jumData];
if($jumData > $dataPerPage){
$jumPage = ceil($jumData/$dataPerPage);
if ($noPage > 1) echo “<< Prev”;
for($page = 1; $page <= $jumPage; $page++){
if ((($page >= $noPage – 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage)){
if (($showPage == 1) && ($page != 2)) echo “…”;
if (($showPage != ($jumPage – 1)) && ($page == $jumPage)) echo “…”;
if ($page == $noPage) echo ” ”.$page.” “; else echo ” ”.$page.” “;
$showPage = $page;
}
}
if ($noPage < $jumPage) echo “Next >>”;
}
echo’
’;
?>
Terima kasih telah membaca artikel tentang Cara membuat pagination sederhana dengan mudah di blog Angka Belia jika anda ingin menyebar-luaskan artikel ini dimohon untuk mencantumkan link sebagai Sumbernya, dan bila artikel ini bermanfaat silahkan bookmark halaman ini di web browser anda, dengan cara menekan Ctrl + D pada tombol keyboard anda.