Function myPageNumber($nowstage,$startpage,$allpage,$nowpage,$pageperstage,$allstage)
{
if(trim($nowpage)>1)
{
$links.=" <<< \n";
}
if(trim($nowstage)>1)
{
$links.=" << \n";
}
for($i=$startpage;$i<=$allpage;$i++)
{
if(trim($nowpage)=="")
{
$nowpage=$startpage;
}
$endpage=(($startpage+$pageperstage)-1);
if($i>=$startpage&&$i<=$endpage&&$i<=$allpage)
{
if($nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$i==$startpage&&$nowpage>$startpage)
{
$links=$links." < \n";
}
if(((($nowstage-1)*$pageperstage)+$i)==$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
{
$links=$links." ".((($nowstage-1)*$pageperstage)+$i)." ";
}
if(((($nowstage-1)*$pageperstage)+$i)!=$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
{
$links=$links." ".((($nowstage-1)*$pageperstage)+$i)." \n";
}
if(($i==$endpage||$i==$allpage)&&$nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$allpage>$nowpage)
{
$links=$links." > \n";
}
}
}
if($nowstage<$allstage)
{
$links=$links. " >> \n";
}
if($nowpage<$allpage)
{
$links.=" >>> \n";
}
return $links;
}
$number="100"; // record results selected from database
$displayperpage="5"; // record displayed per page
$pageperstage="5"; // page displayed per stage
$allpage=ceil($number/$displayperpage); // how much page will it be ?
$allstage=ceil($allpage/$pageperstage); // how many page will it be ?
if(trim($startpage)==""){$startpage=1;}
if(trim($nowstage)==""){$nowstage=1;}
if(trim($nowpage)==""){$nowpage=$startpage;}
?>
Records result from query statement : =$number;?> record.
Want to show =$displayperpage;?> in every page.
Want to show only =$pageperstage;?> page on every stage.
Then there would be =$allpage;?> page of results.
And there would be =$allstage;?> stage of pages.
PAGING : =myPageNumber($nowstage,$startpage,$allpage,$nowpage,$pageperstage,$allstage);;?>
Stage =$nowstage." of ".$allstage;?>
Page =$nowpage." of ".$allpage;?>
for($i=1;$i<=$displayperpage;$i++)
{
echo "
".((($nowpage-1)*$displayperpage)+$i);
}
?>