Home >Backend Development >PHP Tutorial >thinkphp implements paging display function

thinkphp implements paging display function

不言
不言Original
2018-06-07 15:42:274601browse

This article mainly introduces the paging display function of thinkphp to everyone in detail. It has a certain reference value. Interested friends can refer to it.

First, I went to the renderings, and suddenly found that it was on site B. Same

IndexController.class.php code is as follows

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(&#39;theme&#39;,&#39;%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%<p id="pageTips">第 &#39;.I(&#39;p&#39;,1).&#39; 页/共 %TOTAL_PAGE% 页 ( &#39;.$pageCount.&#39; 条/页 共 %TOTAL_ROW% 条信息)</p>&#39;);
    $show = $page->show();
    $list = $m->where($where)->order(&#39;id desc&#39;)->limit($page->firstRow.&#39;,&#39;.$page->listRows)->select();
    $this->assign(&#39;infoList&#39;,$list);
    $this->assign(&#39;show&#39;,$show);
    $this->display();  
  }

index.html code is as follows

      <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=&#39;vo&#39;>

          <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>

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

css code is as follows

/* 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 分页样式 */

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

thinkPHP implements the function of linkage menu

thinkPHP framework implements image cropping, scaling, and watermarking method

The above is the detailed content of thinkphp implements paging display function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn