ThinkPHP完美实现分页和美化

avatar 2016年08月09日18:34:18 0 3125 views
博主分享免费Java教学视频,B站账号:Java刘哥
先上效果图,突然发现和B站上一样 这里写图片描述 IndexController.class.php代码如下
  1. public function index(){
  2.        $m=M('Info');
  3.        $count = $m->where($where)->count();
  4.        $pageCount = 10;//每页显示数量
  5.        $page = new \Think\Page($count , $pageCount);
  6.        $page->parameter = $row//此处的row是数组,为了传递查询条件
  7.        $page->setConfig('header','条留言');
  8.        $page->setConfig('first','首页');
  9.        $page->setConfig('prev','上一页');
  10.        $page->setConfig('next','下一页');
  11.        $page->setConfig('last','尾页');
  12.        $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<div id="pageTips">第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pageCount.' 条/页 共 %TOTAL_ROW% 条信息)</div>');
  13.        $show = $page->show();
  14.        $list = $m->where($where)->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
  15.        $this->assign('infoList',$list);
  16.        $this->assign('show',$show);
  17.        $this->display();
  18.     }
index.html代码如下
  1. <table class="table table-hover table-striped" id="table">
  2.                     <tr class="danger">
  3.                         <th>类别</th>
  4.                         <th>信息标题</th>
  5.                         <th>物品类型</th>
  6.                         <th>遗失/拾物时间</th>
  7.                         <th>遗失/拾物地点</th>
  8.                         <th >发布时间</th>
  9.                     </tr>
  10.                     <foreach name="infoList" item='vo'>
  11.                     <tr >
  12.                         <td>{$vo.info_type}</td>
  13.                         <td>{$vo.info_title}</td>
  14.                         <td>{$vo.thing_type}</td>
  15.                         <td>{$vo.info_time}</td>
  16.                         <td>{$vo.info_place}</td>
  17.                         <td>{$vo.create_time}</td>
  18.                     </tr>
  19.                     </foreach>
  20.             </table>
  21.              <div class="page">
  22.                     <ul>
  23.                         {$show}
  24.                     </ul>
  25.             </div>
css代码如下
  1. /* start 分页样式 */
  2. .page{
  3.     overflow:hidden;
  4.     margin:50px 0 50px 100px;;
  5. }
  6. .page ul a,.page ul span{
  7.     float:left;
  8.     display:inline-block;
  9.     padding: 0 17px;
  10.     height:40px;
  11.     width:auto;
  12.     border:1px solid #DDDDDD;
  13.     border-radius: 4px;
  14.     background:#fff;
  15.     text-align:center;
  16.     line-height:40px;
  17.     margin-right:10px;
  18.     font-family"microsoft yahei" simhei sans-serif;
  19.     color:#7d7d7d;
  20. }
  21. .page ul a:hover{
  22.     background:#337AB7;
  23.     color:#fff;
  24.     text-decoration:none;
  25. }
  26. .page ul span.current{
  27.     background#337AB7;
  28.     color:#fff;
  29. }
  30. .page ul a:first,.page ul a:last{
  31.     float:left;
  32.     display:inline-block;
  33.     width:40px;
  34.     height:40px;
  35.     border-radius:50%;
  36.     background:rgb(215, 215, 217);
  37.     text-align:center;
  38.     line-height:40px;
  39.     margin-right:10px;
  40.     font-family"microsoft yahei" simhei sans-serif;
  41. }
  42. #pageTips {
  43.     float:rightright;
  44. }
  45. /* end 分页样式 */
    本文地址:http://liuyanzhao.com/3485.html 转载请注明  
  • 微信
  • 交流学习,有偿服务
  • weinxin
  • 博客/Java交流群
  • 资源分享,问题解决,技术交流。群号:590480292
  • weinxin
avatar

发表评论

avatar 登录者:匿名
匿名评论,评论回复后会有邮件通知

  

已通过评论:0   待审核评论数:0