<?php
include("page.class.php");
// connection to the database
mysql_connect('localhost', 'root', '');
// select database
mysql_select_db('pager');
// start pager class
$pager = new Pager();
// page number
$pager->PageNumber=$_GET[PageNumber];
// you can change perpage record
$pager->PerPages = 5;
// you can change link page number limit
$pager->PageNumberLimit = 5;
// sql query
$pager->sql_query('SELECT * FROM books');
echo "<br>Total Pages: ".$pager->TotalPage();
echo "<br>Total Records: ".$pager->TotalRecord();
echo "<br>Current Page : ".$pager->PageNumber();
echo "<br>Next Page : ".$pager->NextPage();
echo "<br>Previous Page : ".$pager->PreviousPage();
echo "<br>Remaining Page : ".$pager->RemainingPage();
echo"<hr>";
// print records
foreach($pager->mysql_fetch() as $row){
echo "<br>".$row['ID']."-".$row['BookName'];
}
echo"<hr>";
// Previous Page Link
if($pager->PreviousPage())
{
echo " <a href='?PageNumber=".$pager->PreviousPage()."'>Previous</a>";
}
// print page link number
foreach($pager->PageLink() as $key=>$value){
if($pager->PageNumber()==$key)
{
echo "<b>".$key."</b>";
}
else
{
echo " <a href='?PageNumber=".$key."'>".$key."</a>";
}
}
// Next Page Link
if($pager->NextPage())
{
echo " <a href='?PageNumber=".$pager->NextPage()."'>Next</a>";
}
?>
|