Home >php教程 >PHP源码 >几款经典php分页程序(1/4)

几款经典php分页程序(1/4)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:26:381200browse
<script>ec(2);</script>

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 末页
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn