欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP查詢(xún)分頁(yè)的實(shí)現(xiàn)代碼

 更新時(shí)間:2017年06月09日 14:22:07   作者:塵中客  
這篇文章主要為大家詳細(xì)介紹了PHP查詢(xún)分頁(yè)的實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了PHP查詢(xún)分頁(yè)的具體代碼,后端基于thinkphp框架,供大家參考,具體內(nèi)容如下 

前端需要dataTables插件:傳送門(mén)下載地址 

HTML代碼 

第一步引入插件

<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css"  rel="external nofollow" >
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>

第二步添加 

<table id="table_id_example" class="display">
 <thead>
 <tr>
  <th>ID</th>
  <th>發(fā)布時(shí)間</th>
  <th>發(fā)布IP</th>
  <th>公告內(nèi)容</th>
 </tr>
 </thead>
 <tbody>
  <volist name="notice" id="vo">
   <tr>
   <td>{$vo.id}</td>
   <td>{$vo.create_time}</td>
   <td>{$vo.create_ip}</td>
   <td>{$vo.notice_content}</td>
   </tr>
  </volist>
 </tbody>
</table> 

第三步JS

 <script>
 $(document).ready( function () {
  $('#table_id_example').DataTable();
 } );
 </script>

PHP代碼

 public function gonggaochakan(){
 /* 公告查看
  */
 $dbNotice = M('notice');//實(shí)例化dbNotice對(duì)象
 $count  = $dbNotice->count();// 查詢(xún)滿(mǎn)足要求的總記錄數(shù)
 $Page  = new \Think\Page($count,$count);// 實(shí)例化分頁(yè)類(lèi) 傳入總記錄數(shù)和每頁(yè)顯示的記錄數(shù)(全部記錄)
 $data = $dbNotice->order('create_time')->limit($Page->firstRow.','.$Page->listRows)->select();//獲得所有記錄
 $this->assign('notice',$data);//傳給模板
 $this->show();
} 

​效果

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論