PHP实现分页功能
2016-11-20 18:23
246 查看
html代码(用表单form 的method用$GET)
PHP代码(注意:在此代码开始最好不要使用if(isset($_get['submit']))这个判断,这句在执行下一页的时候根本不会显示内容,因为下一页后需要再次判断submit。)
JS代码(之所以写这个代码,是由于当我们进入第二页之后,然后再改变查询条件,这时查询出来的结果不是从第一个开始,而是从第二页开始,所以我们这里还需要在查询的时候在js中把p参数(当前页码)设置为1)
<div class="table-responsive table-bordered"><br> <form id="form" method="get" class="form-inline"> <div class="demo"> <div class="form-group"> <div class="label"> <label for="start"> 提现时间 </label> </div> <div class="field"> <input class="input" id="start" name="start" value=""> <input class="input" id="end" name="end" value=""> 4000 </div> </div> <div class="form-group"> <div class="label"> <label for="agentname"> 代理商 </label> </div> <div class="field"> <input class="input" type="text" id="agentname" name="agentname" value=""> </div> </div> <div class="form-group"> <div class="label"> <label for="selete"> 提现状态 </label> </div> <div class="field"> <select class="input" id="selete" name="selete"> <option value="">请选择</option> <option value="通过" >通过</option> <option value="拒绝">拒绝</option> <option value="未审核">未审核</option> </select> </div> </div> <div class="form-group"> <button class="button bg-main float-right" type="submit" id="selecting" name="submit">搜索</button> </div> </div> </form> <table class="table"> <tr> <!-- <th><input type="checkbox"></th>!--> <th style="text-align: center;vertical-align: middle">代理商</th> <th style="text-align: center;vertical-align: middle">级别</th> <th style="text-align: center;vertical-align: middle">提现金额</th> <th style="text-align: center;vertical-align: middle">提现时间</th> <th style="text-align: center;vertical-align: middle">提现IP</th> <th style="text-align: center;vertical-align: middle">提现状态</th> </tr> <volist name="list" id="shenhe"> <tr> <td style="text-align: center;vertical-align: middle;">{$shenhe.agentexamine_name}</td> <td style="text-align: center;vertical-align: middle;">{$shenhe.agentexamine_id}</td> <td style="text-align: center;vertical-align: middle;">{$shenhe.agentexamine_task}</td> <td style="text-align: center;vertical-align: middle;">{$shenhe.agentexamine_time}</td> <td style="text-align: center;vertical-align: middle;">{$shenhe.agentexamine_ip}</td> <td style="text-align: center;vertical-align: middle">{$shenhe.agentexamine_feedback}</td> </tr> </volist> </table> <div id="pageBar" class="pagination" style="float: right"> {$page} </div> </div>
PHP代码(注意:在此代码开始最好不要使用if(isset($_get['submit']))这个判断,这句在执行下一页的时候根本不会显示内容,因为下一页后需要再次判断submit。)
public function paging() { $start = $_GET['start']; $end = $_GET['end']; $agentname = $_GET['agentname']; $selete = $_GET['selete']; //取值 $st = array(array('EGT',$start),array('ELT',$end),'AND');// 构造查询条件//判断在时间范围内 $where=array('agentexamine_time' => $st, 'agentexamine_name' => $agentname, 'agentexamine_feedback' => $selete); $M = M("daili_agentexamine");//实例化 $p=getpage($M,$where,1); // 获取查询参数 /* foreach($map as $key=>$val) { $p->parameter .= "$key=".urlencode($val)."&"; }*/ // 分页显示输出 $page = $p->show(); $shenhe = D('daili_agentexamine')->where($where)->limit($p->firstRow.','.$p->listRows)->select(); // 赋值赋值 $this->assign('page', $page); $this->assign('list', $shenhe); $this->display(); }
JS代码(之所以写这个代码,是由于当我们进入第二页之后,然后再改变查询条件,这时查询出来的结果不是从第一个开始,而是从第二页开始,所以我们这里还需要在查询的时候在js中把p参数(当前页码)设置为1)
<script type="text/javascript"> $(function(){ //查询 $("#selecting").click(function(){ $("#form").attr("action", "__URL__/paging/p/1"); $("#form").submit(); }); } ); </script>
相关文章推荐
- PHP_实现分页功能
- PHP分页功能实现
- php+redis实现注册、删除、编辑、分页、登录、关注等功能示例
- 利用PHP访问数据库_实现分页功能与多条件查询功能的示例
- php基于SQLite实现的分页功能示例
- php 跳转分页 (部分功能实现)
- 基于PHP实现数据分页显示功能
- PHP+Ajax实现的无刷新分页功能详解【附demo源码下载】
- PHP常用功能-php实现分页
- PHP简单实现数字分页功能示例
- html中的a标签用js来实现页面跳转的功能(php分页时做的页面跳转)
- 编写PHP脚本来实现WordPress中评论分页的功能
- PHP学习笔记 2009-8-25 实现分页显示功能
- php对文本文件进行分页功能简单实现
- PHP分页功能使用类封装实现
- PHP+MySQL实现留言板分页功能
- php实现分页功能的3种方法第1/3页
- 编写PHP脚本来实现WordPress中评论分页的功能
- php分页功能的实现,封装好的方法
- PHP实现分页浏览功能