最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

bootstrap-paginator服務(wù)器端分頁使用方法詳解

 更新時間:2020年02月13日 15:14:03   作者:捂汗縣長  
這篇文章主要為大家詳細介紹了bootstrap-paginator服務(wù)器端分頁的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了bootstrap-paginator服務(wù)器端分頁的基本用法,供大家參考,具體內(nèi)容如下

HTML:

<script src="../js/jquery-3.2.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootstrap-paginator.min.js"></script>

 <!-- 主內(nèi)容列表 -->
 <ol class="list-group" id="infoList>
  <li class="list-group-item"><span class="fa fa-cog fa-spin fa-fw"></span>正在讀取數(shù)據(jù)……</li>
</ol>

<!-- 分頁導(dǎo)航器 -->
<div style="text-align:center;">
  <ul id="useroption" class="pagination"></ul>
</div>

JS:

//讀取消息列表*************************************************//
 queryInfoList(paraValue);
 function queryInfoList(bid)
 {
  $.ajax({
   async: true,
   type: "get",
   url: "../php/list.php",//向后端發(fā)送請求,后端為PHP
   dataType: "json", //要求后端返回數(shù)據(jù)為JSON格式
   data: { page: '1',bid:bid,act:'getInfoList' }, //請求參數(shù),首次請求頁碼為1
   cache: false,
   success: function (data)
   {
    
    lis = "";
    for (eachRs in data.rs)
    {//拼接對應(yīng)<li>需要的值
     lis += "<li class='list-group-item'><a title='"+data.rs[eachRs]['title']+"' class='newsLink' href='read.html?id="+data.rs[eachRs]['id']+"'>" + data.rs[eachRs]['title'] + "</a> <span class='text-muted pull-right'>"+data.rs[eachRs]['posttime']+"</span></li>";
    };
    $("#infoList").html(lis);

    var currentPage = data.CurrentPage; //當(dāng)前頁數(shù)
    var pageCount = data.pageCount; //總頁數(shù)
  
    var options = {
     bootstrapMajorVersion: 4, //版本
     currentPage: currentPage, //當(dāng)前頁數(shù)
     totalPages: pageCount, //總頁數(shù)
     numberOfPages: 10,//分頁器顯示10條
     shouldShowPage: true,//是否顯示該按鈕
     itemTexts: function (type, page, current)
     {
      switch (type)
      {
       case "first":
        return "首頁";
       case "prev":
        return "上頁";
       case "next":
        return "下頁";
       case "last":
        return "末頁";
       case "page":
        return page;
      }
     },
     
     //點擊事件,用于通過Ajax來刷新整個list列表
     onPageClicked: function (event, originalEvent, type, page)
     {
      $.ajax({
       async: true,
       url: "../php/list.php",
       type: "get",
       dataType: "json",
       data: { page: page,bid:bid ,act:'getInfoList'},
       cache: false,
       success: function (data)
       {
        lis = "";
        for (eachRs in data.rs)
        {//拼接對應(yīng)<li>需要的值
         lis += "<li class='list-group-item'><a title='"+data.rs[eachRs]['title']+"' class='newsLink' href='read.html?id="+data.rs[eachRs]['id']+"'>" + data.rs[eachRs]['title'] + "</a> <span class='text-muted pull-right'>"+data.rs[eachRs]['posttime']+"</span></li>";
        };
        $("#infoList").html(lis);
       }/*success*/
      });
     }
    };
    $('#useroption').bootstrapPaginator(options);
   }/*success*/
  });
 }

PHP:

if($act=='getInfoList')
{
 $bid=addslashes($_REQUEST['bid']);
 $curPage=addslashes($_REQUEST['page']);//當(dāng)前頁碼
 $pageSize=15; //每頁條數(shù)
 $rsAll=$dbh->query("select count(id) from article where board=$bid and wid=30 and auditor is not null and accessable=1")->fetchAll();
 $rsAllCount=$rsAll[0][0];//總記錄數(shù)

 //計算總頁數(shù)
 if($rsAllCount%$pageSize==0)
  $pageAllCount=$rsAllCount/$pageSize;
 else
  $pageAllCount=intval($rsAllCount/$pageSize)+1;

 $beginRs=($curPage-1)*$pageSize; //計算起始記錄
 $curRsSql="select id,title, posttime from article where board=$bid and wid=30 and auditor is not null and accessable=1 order by posttime desc limit $beginRs,$pageSize";
 $rsCur=$dbh->query($curRsSql)->fetchAll();
 echo(json_encode(array("rs"=>$rsCur,"pageCount"=>$pageAllCount,"curPage"=>$curPage,"sql"=>$curRsSql)));
}

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

相關(guān)文章

最新評論

云和县| 梁山县| 涪陵区| 宝清县| 武隆县| 萝北县| 南陵县| 沈丘县| 延津县| 皮山县| 南涧| 芮城县| 同江市| 凌源市| 克东县| 当涂县| 三门县| 馆陶县| 青海省| 孝感市| 祁门县| 浦城县| 内黄县| 岳西县| 嘉义县| 那曲县| 都匀市| 许昌县| 乌海市| 芦山县| 高安市| 厦门市| 庄河市| 雅江县| 突泉县| 呈贡县| 扎鲁特旗| 南木林县| 体育| 泌阳县| 香港 |