//*
// Function, which automaticly prints a page-navigation,
// when there are more entries which are returned from
// a database then should be printed on a page
//
//
// The function needs three parameter
//
// 1. allEntries: Integer, Number of all DB-Entries
// 2. limitBy: Integer, Number of Entries, which are printed on one Page
// 3. limitStart: Integer, Offset
//
//
function showPageNavigation($allEntries, $limitStart=0, $limitBy=20)
{
$lastPageEntries = ($allEntries % $limitBy);
$allPages = round(($allEntries - $lastPageEntries) / $limitBy)+1;
if($lastPageEntries>0 and $allPages==0) {$allPages=$allPages+1;}
$thisPage = round(($limitStart+$limitBy) / $limitBy);
print "
Page ".$thisPage." of ".$allPages."
";
if($allEntries > $limitBy)
{
print "Pages: ";
for($entryNr=1; $entryNr<=$allPages; $entryNr++)
{
$startPage = ($entryNr * $limitBy) - $limitBy;
if($thisPage!=$entryNr){print "".$entryNr." ";}
else{print "".$entryNr." ";}
}
}
$startNext = $thisPage * $limitBy;
if($startNext < ($allPages * $limitBy) and $allEntries > $limitBy)
{print " next ";}
}
?>
if(!isset($limitStart)){$limitStart = 0;}
showPageNavigation(130,$limitStart,20);
?>