Tp3.2自带分页功能

Tp3.2自带分页功能,优化多数据渲染

后端:

public function index(){
        $User = M('user'); // 实例化User对象
        $count      = $User->count();// 查询满足要求的总记录数
        $Page       = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show       = $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
        $userres = $User->limit($Page->firstRow.','.$Page->listRows)->order("id desc")->select();
        $this->assign('userres',$userres);// 赋值数据集
        $this->assign('page',$show);// 赋值分页输出
        $this->display(); // 输出模板
    }

 前端:

<table id="exampleTableEvents" data-height="500" data-mobile-responsive="true" >
	<thead>
	<tr>
		<th>操作</th>
		<th data-field="title">评论</th>
	</tr>
	</thead>
    <volist name="cmtlistres" id="res">
	    <tr>
		<td>
		<a href="#" class="glyphicon glyphicon-trash" onclick="myDelate(this)" data-id="{$res.id}">删除</a>
		</td>
		<td>{$res.content}</td>
	    </tr>
	</volist>
</table>
<div class="my_pages">{$page}</div>

css:

.my_pages{float: right}
.my_pages a,.my_pages span {
    display:inline-block;
    padding:2px 10px;
    border:1px solid #f0f0f0;
    -webkit-border-radius:3px;
    -moz-border-radius:3px;
    border-radius:3px;
    font-size: 14px;
}
.my_pages a,.my_pages li {
    display:inline-block;
    list-style: none;
    text-decoration:none; color:#58A0D3;
}
.my_pages a.first,.my_pages a.prev,.my_pages a.next,.my_pages a.end{
    margin:0 auto;
}
.my_pages a:hover{
    border-color:#50A8E6;
}
.my_pages span.current{
    background:#50A8E6;
    color:#FFF;
    font-weight:700;
    border-color:#50A8E6;
}

效果:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dove言和

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值