ThinkPHP完美实现分页和美化

先上效果图,突然发现和B站上一样
这里写图片描述

IndexController.class.php代码如下

public function index(){
       $m=M('Info');       
       $count = $m->where($where)->count();
       $pageCount = 10;//每页显示数量
       $page = new \Think\Page($count , $pageCount);
       $page->parameter = $row; //此处的row是数组,为了传递查询条件
       $page->setConfig('header','条留言');
       $page->setConfig('first','首页');
       $page->setConfig('prev','上一页');
       $page->setConfig('next','下一页');
       $page->setConfig('last','尾页');
       $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<div id="pageTips">第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pageCount.' 条/页 共 %TOTAL_ROW% 条信息)</div>');
       $show = $page->show();
       $list = $m->where($where)->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
       $this->assign('infoList',$list);
       $this->assign('show',$show);
       $this->display();   
    }

index.html代码如下

            <table class="table table-hover table-striped" id="table">
                    <tr class="danger">
                        <th>类别</th>
                        <th>信息标题</th>
                        <th>物品类型</th>
                        <th>遗失/拾物时间</th>
                        <th>遗失/拾物地点</th>
                        <th >发布时间</th>
                    </tr>
                    <foreach name="infoList" item='vo'>

                    <tr >
                        <td>{$vo.info_type}</td>
                        <td>{$vo.info_title}</td>
                        <td>{$vo.thing_type}</td>
                        <td>{$vo.info_time}</td>
                        <td>{$vo.info_place}</td>
                        <td>{$vo.create_time}</td>
                    </tr>
                    </foreach>
            </table>

             <div class="page">
                    <ul>
                        {$show}
                    </ul>
            </div>

css代码如下


/* start 分页样式 */

.page{
    overflow:hidden;
    margin:50px 0 50px 100px;;
}

.page ul a,.page ul span{
    float:left;
    display:inline-block;
    padding: 0 17px;
    height:40px;
    width:auto;
    border:1px solid #DDDDDD;
    border-radius: 4px;
    background:#fff;
    text-align:center;
    line-height:40px;
    margin-right:10px;
    font-family: "microsoft yahei" simhei sans-serif;
    color:#7d7d7d;
}

.page ul a:hover{
    background:#337AB7;
    color:#fff;
    text-decoration:none;
}

.page ul span.current{
    background: #337AB7;
    color:#fff;
}


.page ul a:first,.page ul a:last{
    float:left;
    display:inline-block;
    width:40px;
    height:40px;
    border-radius:50%;
    background:rgb(215, 215, 217);
    text-align:center;
    line-height:40px;
    margin-right:10px;
    font-family: "microsoft yahei" simhei sans-serif;
}

#pageTips {
    float:right;
}
/* end 分页样式 */

本文地址:http://liuyanzhao.com/3485.html

转载请注明

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

半缘修道半缘君丶

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

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

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

打赏作者

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

抵扣说明:

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

余额充值