84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
|
|
<?php
|
||
|
|
extract($_REQUEST);
|
||
|
|
|
||
|
|
function recordsetNav(&$r_count,$page_url,$container,$offset=0,$limit=0,$verbiage=1,$extraurl='',$blocksize=20)
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
$totalrecords = $r_count;
|
||
|
|
$pagenumber = intval(($offset + $limit) / $limit);
|
||
|
|
$totalpages = intval($totalrecords/$limit);
|
||
|
|
|
||
|
|
if ($totalrecords%$limit > 0) // partial page
|
||
|
|
{
|
||
|
|
$lastpage = $totalpages * $limit;
|
||
|
|
$totalpages++;
|
||
|
|
} else {
|
||
|
|
$lastpage = ($totalpages - 1) * $limit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// start building navigation string
|
||
|
|
$navstring = "";
|
||
|
|
|
||
|
|
if ($totalrecords > $limit) // only show <<PREV NEXT>> row if $totalrecords is greater than $limit
|
||
|
|
{
|
||
|
|
|
||
|
|
if ($offset != 0)
|
||
|
|
{
|
||
|
|
$navstring .= "<a title='First Page' class='MENUsmall' href=\"javascript:getcontent('".$page_url."?offset=0','".$container."')\"><strong>|<</strong></a> ";
|
||
|
|
$navstring .= "<a title='Previous Page' class='MENUsmall' href=\"javascript:getcontent('".$page_url."?offset=".($offset-$limit).$extraurl.",'".$container."')\"><strong><</strong></a> ";
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($totalpages < $blocksize)
|
||
|
|
{
|
||
|
|
$blocksize = $totalpages;
|
||
|
|
$firstpage = 1;
|
||
|
|
} elseif ($pagenumber > $blocksize) {
|
||
|
|
$firstpage = ($pagenumber-$blocksize) + 2;
|
||
|
|
} elseif ($pagenumber == $blocksize) {
|
||
|
|
$firstpage = 2;
|
||
|
|
} else {
|
||
|
|
$firstpage = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
$blocklimit = $blocksize + $firstpage;
|
||
|
|
|
||
|
|
// Page numbers
|
||
|
|
|
||
|
|
|
||
|
|
for ($i=$firstpage;$i < $blocklimit;$i++)
|
||
|
|
{
|
||
|
|
if ($i == $pagenumber)
|
||
|
|
{
|
||
|
|
$navstring .= "<span class='ATTENTIONsmall'>$i</span> ";
|
||
|
|
} else {
|
||
|
|
if ($i <= $totalpages)
|
||
|
|
{
|
||
|
|
$nextoffset = $limit * ($i-1);
|
||
|
|
$navstring .= "<a title='Page ". $i ." of ". $totalpages ."' class='small' href=\"javascript:getcontent('".$page_url."?offset=".$nextoffset.$extraurl."','".$container."')\">$i</a> ";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if($totalrecords-$offset > $limit)
|
||
|
|
{
|
||
|
|
$navstring .= " <a title='Next Page' class='MENUsmall' href=\"javascript:getcontent('".$page_url."?offset=".($offset+$limit).$extraurl."','".$container."')\"><strong>></strong></a> ";
|
||
|
|
$navstring .= "<a title='Last Page' class='MENUsmall' href=\"javascript:getcontent('".$page_url."?offset=".$lastpage.$extraurl."','".$container."')\"><strong>>|</strong></a>";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ($verbiage)
|
||
|
|
{
|
||
|
|
$navstring .= "";
|
||
|
|
$navstring .= "<span class='RGBsmall'>page: <strong>".$pagenumber."</strong>/<strong>".$totalpages."</strong>";
|
||
|
|
$navstring .= " total records: <strong>".$totalrecords."</strong></span>";
|
||
|
|
}
|
||
|
|
$navstring .= "";
|
||
|
|
|
||
|
|
echo $navstring;
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|