Site Navigation Php

class paging {
function paging () {
$this->rowperpage = 50;
$this->pageperstg = 20;
}
function getPaging($rownum, $pg="1", $stg="1") {
$arr = explode("&",$_SERVER["QUERY_STRING"]);
if (is_array($arr)) {
for ($i=0;$i if (!is_int(strpos($arr[$i],"pg=")) && !is_int(strpos($arr[$i],"stg=")) && trim($arr[$i]) != "") $qs .= $arr[$i]."&";
}
}
if ($this->rowperpage<$rownum) {
$allpage = ceil($rownum/$this->rowperpage);
$allstg = ceil($allpage/$this->pageperstg);
$minpage = (($stg-1)*$this->pageperstg)+1;
$maxpage = $stg*$this->pageperstg;
if ($maxpage>$allpage) $maxpage = $allpage;
if ($allpage>1) {
$rtn = "
";
if ($stg>1) $rtn .= "Previous Stage | ";
if ($pg>1) {
if ($pg==$minpage) {
$rtn .= "Previous | ";
} else {
$rtn .= "Previous | ";
}
}
for ($i=$minpage;$i<=$maxpage;$i++) {
if ($i==$pg) {
$rtn .= "$i | ";
} else {
$rtn .= "$i | ";
}
}
if ($pg<=$maxpage) {
if ($pg==$maxpage && $stg<$allstg) {
$rtn .= " Next | ";
} elseif ($pg<$maxpage) {
$rtn .= " Next | ";
}
}
if ($stg<$allstg) $rtn .= "Next Stage | ";
$rtn = substr($rtn,0,strlen($rtn)-3);
$rtn .= "
";
return $rtn;
}
}
}
};
?>