function _pageft($totle, $displaypg = 20, $url = '') {
global $page, $firstcount, $pagenav, $_server;
$globals["displaypg"] = $displaypg;
if (!$page)
$page = 1;
if (!$url) {
$url = $_server["request_uri"];
}
//url分析:
$parse_url = parse_url($url);
$url_query = $parse_url["query"]; //单独取出url的查询字串
if ($url_query) {
$url_query = ereg_replace("(^|&)page=$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); //最后页,也是总页数
$page = min($lastpg, $page);
$prepg = $page -1; //上一页
$nextpg = ($page == $lastpg ? 0 : $page +1); //下一页
$firstcount = ($page -1) * $displaypg;
//开始分页导航条代码:
$pagenav = "显示第 " . ($totle ? ($firstcount +1) : 0) . "-" . min($firstcount + $displaypg, $totle) . " 条记录,共 $totle 条记录";
首页 1 2 3 4
末页
本文原创发布php中文网,转载请注明出处,感谢您的尊重!