简单的封装了一个分页类,太长发不了,只好放在附件中,本文最后可以下载。
应用实例,pager_test.php:
- <style>
- a{text-decoration:none;color:#069}
- .pager{color:gray;list-style:none;}
- .pager li{float:left;text-align:center;}
- .pager li.link{margin:3px 7px;text-align:center;}
- .pager li.link a{width:100%;display:block;padding:3px 3px;border:1px solid #ddd;}
- .pager li.link a:hover{background:#09f;color:#fff;width:100%;border:1px solid #069;}
- .pager li.current_page{margin:3px 10px;font-weight:bold;color:black;}
- .pager li.current_page span{width:100%;text-align:center;display:block;padding:4px 5px;}
- .pager li.no_page{margin:3px;padding:4px 5px 0px 5px;font-weight:bold;}
- .pager li.stat{margin:3px;padding:4px 5px 0px 5px;color:black}
- .pager li.region{margin:3px;padding:4px 5px 0px 5px;color:black}
- .pager li.input{margin:3px;padding:2px 5px 0px 5px;}
- </style>
- <?php
- require 'Pager.php';
- $Pager = new Pager();
- $curr_page = empty($_GET["page"]) || $_GET["page"] < 1 ? 1 : (int)$_GET["page"];
- unset($_GET['page']);
- $config['base_url'] = 'pager_test.php?'.http_build_query($_GET);
- $config['current_page'] = $curr_page;
- $config['total_num'] = 10000;
- $config['first_page_txt'] = "首页";
- $config['pre_page_txt'] = "前一页";
- $config['next_page_txt'] = "后一页";
- $config['last_page_txt'] = "尾页";
- $config['stat_format'] = "共%d条";
- $config['region_format'] = "当前%d - %d";
- $config['perpage'] = 20;
- $config['etc_num'] = 1;
- $config['is_show_link_list'] = true;
- $config['is_show_begin_end'] = true;
- $config['is_show_stat'] = true;
- $config['is_show_region'] = true;
- $config['is_show_begin_etc'] = false;
- $config['is_show_end_etc'] = true;
- $config['container_tag_class'] = "pager";
- $config['item_tag_class_stat'] = "stat";
- $config['item_tag_class_region'] = "region";
- $config['item_tag_class_link'] = "link";
- $config['item_tag_class_nolink'] = "no_page";
- $config['item_tag_class_current'] = "current_page";
- $config['item_tag_class_input'] = "input";
- /*
- $config['txt_tag_class_nolink'] = "";
- $config['txt_tag_class_current'] = "";
- $config['txt_tag_class_stat'] = "txt";
- $config['txt_tag_class_region'] = "txt";
- $config['jump_input_class'] = "jump";
- */
- $Pager->init($config);
- $str = $Pager->create();
- echo $str;
截图如下:
本文转自 ustb80 51CTO博客,原文链接:http://blog.51cto.com/ustb80/1045705,如需转载请自行联系原作者