+-----------------------------------------------------------------------
| File Summary: Pagination display function
| File name: page.php
| Date Created: 2010-5-20
+-----------------------------------------------------------------------
*/
function _pageft ($totle, $displaypg = $url = ') {
Global $page, $firstcount, $pagenav, $_server;
$globals ["displaypg"] = $DISPLAYPG;
if (! $page)
$page = 1;
if (! $url) {
$url = $_server["Request_uri"];
}
//url Analysis:
$parse _url = Parse_url ($url);
$url _query = $parse _url["Query "]; Query string
if ($url _query) {
$url _query = Preg_replace ("/(^|&) page=$" for individual removal of URLs page/"," ", $url _query);
$url = str_replace ($parse _url["Query"), $url _query, $url);
if ($url _query)
$url. = "&page";
else
$url. = "page";
} else {
$url. = "? page";
}
$lastpg = ceil ($totle /$DISPLAYPG); Last page, is also the total number of pages
$page = min ($lastpg, $page);
$PREPG = $page-1;//prev
$ NEXTPG = ($page = = $LASTPG 0: $page + 1); Next page
$firstcount = ($page-1) * $DISPLAYPG;
To start the pager bar code:
$pagenav = "Show <b>". ($totle? ($firstcount + 1): 0). "</b>-<b>". Min ($firstcount + $DISPLAYPG, $totle). "</b> Records total <font color= ' red ' > $totle </font> message";
If only one page jumps out of the function:
if ($LASTPG <= 1)
return false;
$pagenav. = "<a href= ' $url =1 ' > Home </a>";
if ($PREPG)
$pagenav. = "<a href= ' $url = $prepg ' > front page </a>";
Else
$pagenav. = "front page";
if ($NEXTPG)
$pagenav. = "<a href= ' $url = $nextpg ' > Back page </a>";
Else
$pagenav. = "Back Page";
$pagenav. = "<a href= ' $url = $lastpg ' > Last </a>";
Drop-down Jump List, looping through all page numbers:
$pagenav. = "to <select class= ' border:1px solid #98ccfa; ' name= ' topage ' size= ' 1 ' onchange= ' window.location= ' $url =" + This.value ' >n ';
for ($i = 1; $i <= $lastpg; $i + +) {
if ($i = = $page)
$pagenav. = "<option value= ' $i ' selected> $i </option>n";
Else
$pagenav. = "<option value= ' $i ' > $i </option>n";
}
$pagenav. = "</select> page total <font color= ' red ' > $lastpg </font> page";
}
?>