hi,
i want to try a page navigator to my page. iam using the following class.
It works fine. The problem is i want the "next" hyperlink to display the next 10 pages' links.
i.e. 1 2 3 4 5 6 7 8 9 10 Next[10]
My code now displays the 11 th page if u click on Next[10]
it should display 10 11 12 13 etc.
this is the class
<?php
class MySQLPagedResultSet
{
var $results;
var $pageSize;
var $page;
var $row;
//$resultpage=null;
function MySQLPagedResultSet($query,$pageSize,$cnx)
{
global $resultpage;
//$resultpage=$_GET['resultpage'];
$this->results = @mysql_query($query,$cnx);
$this->pageSize = $pageSize;
if ((int)$resultpage <= 0) $resultpage = 1;
if ($resultpage > $this->getNumPages())
$resultpage = $this->getNumPages();
$this->setPageNum($resultpage);
}
function getNumPages()
{
if (!$this->results)
return FALSE;
return ceil(mysql_num_rows($this->results) /
(float)$this->pageSize);
}
function setPageNum($pageNum)
{
if ($pageNum > $this->getNumPages() or
$pageNum <= 0) return FALSE;
$this->page = $pageNum;
$this->row = 0;
mysql_data_seek($this->results,($pageNum-1) * $this->pageSize);
}
function getPageNum()
{
return $this->page;
}
function isTenPage()
{
return ($this->page >= 3);
}
function isLastPage()
{
return ($this->page >= $this->getNumPages());
}
function isFirstPage()
{
return ($this->page <= 1);
}
function fetchArray()
{
if (!$this->results)return FALSE;
if ($this->row >= $this->pageSize) return FALSE;
$this->row++;
return mysql_fetch_array($this->results);
}
function getPageNav($queryvars = '')
{
$nav=null;
if (!$this->isFirstPage())
{
$nav .= "<a href=\"?resultpage=".
($this->getPageNum()-1).'&'.$queryvars.'">Prev</a> ';
}
if ($this->getNumPages() > 1)
for ($i=1; $i<=$this->getNumPages(); $i++)
{
if ($i==$this->page)
$nav .= "$i ";
else
$nav .= "<a href=\"?resultpage={$i}&".
$queryvars."\">{$i}</a> ";
}
if (!$this->isLastPage())
{
$nav .= "<a href=\"?resultpage=".
($this->getPageNum()+1).'&'.$queryvars.'">Next</a> ';
}
return $nav;
}
}
?>
Any help would be appreciated
Thanks in advance
shanthy