index.html
<!--头部要引用bootstrap相关文件哦-->
<style type="text/css">
a{ color:black; text-decoration:none;} a:hover{ color:#2e2d3d; text-decoration:none;}
#showBox b{ float:left;}
</style>
<div id="showBox"><b>显示条数:</b> <div class="btn-group"> <button type="button" class="btn btn-default">显示{$num}条</button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="{:U('Examinee/index?num=10')}">10</a></li> <li><a href="{:U('Examinee/index?num=15')}">15</a></li> <li><a href="{:U('Examinee/index?num=20')}">20</a></li> <li><a href="{:U('Examinee/index?num=25')}">25</a></li> <li><a href="{:U('Examinee/index?num=30')}">30</a></li> </ul> </div> </div>
后台action中(我用的thinkphp)
public function index(){
if($num=I("num")){ //接收每页显示信息条数 $num=I("num"); }else{ $num=10; //页面一开始只加载10条数据 }
/*以下就是thinkphp的分页查询啦,可以自己看文档哦:),http://document.thinkphp.cn/manual_3_2.html#data_page
将文档中显示中这一行的25替换成变量$num就可以使用啦
$Page = new \Think\Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数(25) */}