<?php
Prohibit direct access to this page
if (basename ($HTTP _server_vars[' php_self ']) = = "pager.class.php") {
Header ("http/1.0 404 Not Found");
}
Class Pager
{
Total information of/** * *
var $infoCount;
/** Total Pages * *
var $pageCount;
/** per-page display number of bars * *
var $items;
/** Current Page Number * *
var $pageNo;
/** the starting position of the query * *
var $startPos;
var $nextPageNo;
var $prevPageNo;
function Pager ($infoCount, $items, $pageNo)
{
$this->infocount = $infoCount;
$this->items = $items;
$this->pageno = $pageNo;
$this->pagecount = $this->getpagecount ();
$this->adjustpageno ();
$this->startpos = $this->getstartpos ();
}
function Adjustpageno ()
{
if ($this->pageno = = ' | | $this->pageno < 1)
$this->pageno = 1;
if ($this->pageno > $this->pagecount)
$this->pageno = $this->pagecount;
}
/**
* Next Page
*/
function Gotonextpage ()
{
$nextPageNo = $this->pageno 1;
if ($nextPageNo > $this->pagecount)
{
$this->nextpageno = $this->pagecount;
return false;
}
$this->nextpageno = $nextPageNo;
return true;
}
/**
* Previous Page
*/
function Gotoprevpage ()
{
$prevPageNo = $this->pageno-1;
if ($prevPageNo < 1)
{
$this->prevpageno = 1;
return false;
}
$this->prevpageno = $prevPageNo;
return true;
}
function Getpagecount ()
{
Return Ceil ($this->infocount/$this->items);
}
function Getstartpos ()
{
Return ($this->pageno-1) * $this->items;
}
}
?>