本文实例讲述了PHP封装的page分页类定义与用法。分享给大家供大家参考,具体如下:
亲测有效,见下图=========>
1. 测试实例test.php
<"Content-Type: text/html; charset=utf-8"); date_default_timezone_set("Asia/Shanghai"); //时区 require_once('page.class.php'); $showrow = 5; $curpage = empty($_GET['page']) ""; $dsn = 'mysql:host=xxx.xxx.80.xxx;dbname=admin'; $pdo = new PDO($dsn, 'root', 'root'); $pdo->query('set names utf8'); $sql = "SELECT * from operator_list where 1=1"; $res_gg = $pdo->query("SELECT count(*) as ctn from operator_list where 1=1;"); $result = $res_gg->fetch(); $total = $result["ctn"]; if (!empty($_GET['page']) && $total != 0 && $curpage > ceil($total / $showrow)) { $curpage = ceil($total_rows / $showrow); } $sql .= " LIMIT " . ($curpage - 1) * $showrow . ",$showrow;"; $res_zz = $pdo->query($sql); $result = $res_zz->fetchAll(); //print_r(json_encode($result));die; "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <meta name="keywords" content="入库"/> <meta name="description" content="入库"/> <script type="text/javascript" src="/UploadFiles/2021-04-02/jquery-1.11.0.min.js">2. 封装的page分页类page.class.php
<"/^[0-9]+$/", $num)) { $num = 1; } else { $num = substr($num, 0, 11); } } else { $num = 1; } return $num; } //地址替换 private function page_replace($page) { return str_replace("{page}", $page, $this->myde_url); } //首页 private function myde_home() { if ($this->myde_page != 1) { return "<a href='" . $this->page_replace(1) . "' title='首页'>首页</a>"; } else { return "<p>首页</p>"; } } //上一页 private function myde_prev() { if ($this->myde_page != 1) { return "<a href='" . $this->page_replace($this->myde_page - 1) . "' title='上一页'>上一页</a>"; } else { return "<p>上一页</p>"; } } //下一页 private function myde_next() { if ($this->myde_page != $this->myde_page_count) { return "<a href='" . $this->page_replace($this->myde_page + 1) . "' title='下一页'>下一页</a>"; } else { return"<p>下一页</p>"; } } //尾页 private function myde_last() { if ($this->myde_page != $this->myde_page_count) { return "<a href='" . $this->page_replace($this->myde_page_count) . "' title='尾页'>尾页</a>"; } else { return "<p>尾页</p>"; } } //输出 public function myde_write($id = 'page') { $str = "<div id=" . $id . ">"; $str.=$this->myde_home(); $str.=$this->myde_prev(); if ($this->myde_i > 1) { $str.="<p class='pageEllipsis'>...</p>"; } for ($i = $this->myde_i; $i <= $this->myde_en; $i++) { if ($i == $this->myde_page) { $str.="<a href='" . $this->page_replace($i) . "' title='第" . $i . "页' class='cur'>$i</a>"; } else { $str.="<a href='" . $this->page_replace($i) . "' title='第" . $i . "页'>$i</a>"; } } if ($this->myde_en < $this->myde_page_count) { $str.="<p class='pageEllipsis'>...</p>"; } $str.=$this->myde_next(); $str.=$this->myde_last(); $str.="<p class='pageRemark'>共<b>" . $this->myde_page_count . "</b>页<b>" . $this->myde_total . "</b>条数据</p>"; $str.="</div>"; return $str; } } "htmlcode">html, body, div, span, h1, h2, h3, h4, h5, h6, p, pre, a, code, em, img, small, strong, sub, sup, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent } a { color: #007bc4; text-decoration: none; cursor: pointer; } .table_parameters a:hover { text-decoration: none } a:hover { text-decoration: underline } ol, ul { list-style: none } table { border-collapse: collapse; border-spacing: 0 } /*html {*/ /*background: url(../images/demo_bg.png)*/ /*}*/ body { height: 100%; font: 12px/18px "Microsoft Yahei", Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif; color: #51555c } img { border: 0; cursor: pointer; } .clearfix:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0 } .head { /*border-bottom: 1px solid #dadada;*/ padding: 0 0 5px } .head_inner { margin: 0 auto; width: 980px } .container { width: 80%; /*min-height: 600px;*/ margin: 30px auto 0 auto; border: 1px solid #d3d3d3; background: #fff; -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px } .demo > h2.title { margin: 4px 0 30px; padding: 15px 0 10px 20px; border-bottom: 1px solid #d3d3d3; font-size: 18px; color: #a84c10; background: url(../images/arrow.jpg) no-repeat 2px 14px } .foot { height: 60px; padding: 10px 2px; line-height: 24px; text-align: center } .foot a:hover { color: #51555c } .btn { -webkit-border-radius: 3px; -moz-border-radius: 3px; -ms-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; background-color: #ff8400; color: #fff; display: inline-block; height: 28px; line-height: 28px; text-align: center; padding: 0 12px; transition: background-color .2s linear 0s; border: 0; cursor: pointer } .btn:hover { background-color: #e95a00; text-decoration: none } .demo { width: 700px; margin: 0 auto } ul.ul_demo li { background: url("../images/demo_icon.gif") no-repeat scroll 0 6px; line-height: 28px; padding-left: 20px } .input, .table input[type='text'] { border: 1px solid #ccc; padding: 0 5px; width: 220px; height: 26px; line-height: 26px } #nav { float: right; margin: 30px 0 0 } #nav li { float: left; font-size: 16px; margin-right: 20px } .btn.loading { opacity: .5 } h3 a.cur { color: #f30; } .demo h3 a { font-size: 14px; margin: 0 10px 5px 0; display: inline-block } .red { color: red } .notice { font-size: 14px; margin-bottom: 10px; } .table_parameters { border-left: 1px solid #d3d3d3; border-top: 1px solid #d3d3d3; margin: 6px auto; font-size: 14px } .table_parameters tr.tr_head { background: none repeat scroll 0 0 #f7f7f7; font-weight: bold; padding: 6px; text-align: center } .table_parameters td, .table_parameters th { border-bottom: 1px solid #d3d3d3; border-right: 1px solid #d3d3d3; line-height: 26px; padding: 2px } h1 { font: 32px "Microsoft Yahei"; margin: 40px auto; text-align: center; } h2 { font-size: 16px; margin: 10px 0; } .menu { height: 30px; margin-bottom: 30px; padding: 10px; background-color: #f0f0f0; text-align: center; } .menu a { display: inline-block; height: 30px; padding: 0 20px; line-height: 30px; font-size: 14px; color: #333; text-decoration: none; } .menu a:hover { color: #000; background-color: #e9e9e9; } .menu .cur { background-color: #ddd !important; color: #000; } .vad a { display: inline-block; height: 36px; line-height: 36px; margin: 0 5px; padding: 0 50px; font-size: 14px; text-align: center; color: #eee; text-decoration: none; background-color: #222; } .vad a:hover { color: #fff; background-color: #000; } .thead { width: 728px; height: 90px; margin: 0 auto; } textarea { border: 1px solid #ccc; font-size: 12px; height: 100px; line-height: 18px; padding: 5px; width: 300px; } .table td { padding: 10px 0 } .disabled { opacity: .6; filter: alpha(opacity=60) } .demo > p { line-height: 30px; font-size: 14px } .demo > p a { font-size: 14px } .demo h3 { font-size: 16px; margin: 20px 0 } select { background-color: #fff; background-position: right center; background-repeat: no-repeat; border: 1px solid #888; border-radius: 3px; box-sizing: border-box; font: 12px/1.5 Tahoma, Arial, sans-serif; height: 30px; padding: 0 4px; } fieldset { border: 1px solid #ccc; border-radius: 5px; margin: 1em 0; padding: 10px 20px; } dl.row dt { width: 2em; } dl.row dt { clear: left; float: left; line-height: 30px; padding: 5px; text-align: right; width: 6em; } dl.row dd { float: left; padding: 5px; } .pager { text-align: right; } .pager a { padding: 3px 8px; margin-left: 3px; line-height: 20px; background: #f9f9f9; border: 1px solid #DBDBDB; text-decoration: none } .pager a:hover, .pager a.current { background-color: #7CD5B1; color: #fff; border: 1px solid #7CD5B1; cursor: pointer; } .page { text-align: center; margin: 50px 0 } .page a, .page span.prev_disabled { border: 1px solid #ededed; color: #3d3d3d; font-weight: 700; height: 35px; line-height: 35px; margin-left: 5px; min-width: 9px; padding: 0 13px; text-align: center; text-decoration: none; vertical-align: top; font-family: "simsun"; display: inline-block } .page span.prev_disabled { cursor: default; color: #ccc; margin: 0 10px 0 0 } .page a.current { background-color: #f40; border-color: #f40; color: #fff; font-weight: 700; position: relative; z-index: 1; } .page .extra { display: inline-block; margin-left: 10px; height: 35px; line-height: 35px; color: #656565; } .page .page-num { border: 1px solid #ededed; height: 21px; text-align: center; width: 35px; display: inline-block } .page .page-submit { background-clip: padding-box; border: 1px solid #ededed; border-radius: 2px; cursor: pointer; height: 21px; line-height: 21px; text-align: center; width: 43px; display: inline-block } .page .page-submit:hover { border-color: #f40; color: #f40; } .page a:focus, .page a:hover { border-color: #f40; z-index: 1; } .loading { margin: 30px 0; text-align: center } p { margin: 0 } #page { height: 40px; padding: 20px 0px; } #page a { display: block; float: left; margin-right: 10px; padding: 2px 12px; height: 24px; border: 1px #cccccc solid; background: #fff; text-decoration: none; color: #808080; font-size: 12px; line-height: 24px; } #page a:hover { color: #077ee3; border: 1px #077ee3 solid; } #page a.cur { border: none; background: #077ee3; color: #fff; } #page p { float: left; padding: 2px 12px; font-size: 12px; height: 24px; line-height: 24px; color: #bbb; border: 1px #ccc solid; background: #fcfcfc; margin-right: 8px; } #page p.pageRemark { border-style: none; background: none; margin-right: 0px; padding: 4px 0px; color: #666; } #page p.pageRemark b { color: red; } #page p.pageEllipsis { border-style: none; background: none; padding: 4px 0px; color: #808080; } .dates li { font-size: 14px; margin: 20px 0 } .dates li span { text-align: center } td { font-size: 15px; margin: 20px 0 }更多关于PHP相关内容感兴趣的读者可查看本站专题:《php+mysql数据库操作入门教程》、《php+mysqli数据库程序设计技巧总结》、《php面向对象程序设计入门教程》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》、《PHP网络编程技巧总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
PHP,封装,page分页类
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。
更新日志
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】