3

独创比百度、Google分页还强的分页类

 1 year ago
source link: https://blogread.cn/it/article/712?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
您现在的位置首页 --> 算法 --> 独创比百度、Google分页还强的分页类

独创比百度、Google分页还强的分页类

浏览:3419次  出处信息

最近忙于游戏,总是觉得没什么好写的,时隔十天得上个重量级的日志了。
上周就完成好了,为以后方便管理于维护,直接封装成方法以后用吧。
给过两个版本的改进,觉得比百度、GG的分页更合理。
共50页的例子,具体可以自行测试:
第1页 1 2 3 4 5 >> 50
第5页 1 << 3 4 5 6 7 >> 50
第7页 1 << 5 6 7 8 9 >> 50
第50页 1 << 46 47 48 49 50

  1. <?php   
  2.  * zhoz智能分页类  
  3.  * $Id: zhoz_com_paging.php  
  4.  * @author zhoz  
  5.  * @access public  
  6.  * @package www.zhoz.com  
  7.  * @zhoz 版权所有 转载或引用请注明出处  
  8. function getPagingTag($url, $page_count, $page_num) {   
  9.   $paging_tag = null;   
  10.   // 每页参数获取与分页处理   
  11.   if ($page_count > 1) {   
  12.     if ($page_num > 3) {   
  13.       if ($page_num - 2 <= 0) {   
  14.         $show_start = 1;   
  15.       } else {   
  16.         $show_start = $page_num - 2;   
  17.       if ($page_num + 2 > $page_count) {   
  18.         $show_end = $page_count;   
  19.       } else {   
  20.         $show_end = $page_num + 2;   
  21.     } else {   
  22.       $show_start = 1;   
  23.       $show_end = 5;   
  24.       if ($show_end > $page_count) {   
  25.         $show_end = $page_count;   
  26.     if ($show_start > 1 && ($show_start >= $page_count - 4)) {   
  27.       $show_start = $page_count - 4;   
  28.     if ($show_end >= $page_count) {   
  29.       $show_end = $page_count;   
  30.     if ($page_num > 3 && $show_start > 1) {   
  31.       $paging_tag = "<a href=\"" . $url . "?page_num=1\">1</a> ";   
  32.       if ($show_start-1 > 1) {   
  33.         $paging_tag .= "<a href=\"" . $url . "?page_num=" . ($show_start-1) . "\"><<</a> ";   
  34.     // 中

    建议继续学习:

    QQ技术交流群:445447336,欢迎加入!
    扫一扫订阅我的微信号:IT技术博客大学习

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK