欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

thinkPHP中怎么實現(xiàn)統(tǒng)計排行與分頁顯示功能-創(chuàng)新互聯(lián)

thinkPHP中怎么實現(xiàn)統(tǒng)計排行與分頁顯示功能,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

成都網(wǎng)站設計、成都網(wǎng)站建設的開發(fā),更需要了解用戶,從用戶角度來建設網(wǎng)站,獲得較好的用戶體驗。成都創(chuàng)新互聯(lián)公司多年互聯(lián)網(wǎng)經(jīng)驗,見的多,溝通容易、能幫助客戶提出的運營建議。作為成都一家網(wǎng)絡公司,打造的就是網(wǎng)站建設產(chǎn)品直銷的概念。選擇成都創(chuàng)新互聯(lián)公司,不只是建站,我們把建站作為產(chǎn)品,不斷的更新、完善,讓每位來訪用戶感受到浩方產(chǎn)品的價值服務。

1.分頁參數(shù)

count總數(shù)
firstRow起始行
listRows每一次獲取記錄數(shù)
list每一頁的記錄(要與count對應一致就行)

2.分頁對象

可以針對真實的數(shù)據(jù)表
也可以針對統(tǒng)計出來的數(shù)據(jù)表,或者說是虛擬的表
因為LIMIT是最后執(zhí)行的,哪怕你進行group操作,哪怕你進行子查詢

html

<include file="Public:head" title="" />
<style type="text/css">
.top {
  font-size: 18px;
  border-bottom: #ddd 1px solid;
  margin-bottom: -1px;
  font-weight: bold;
}
.top .title {
  margin:10px;
  border:1px solid #EF6C00;
  display:-webkit-box;
  border-radius: 3px;
}
.top .title .title_child {
  width: 50%;
  line-height:40px;
  -webkit-box-flex:1;
  display:block;
  color:#EF6C00;
  text-decoration:none;
}
.top .title .title_child.active {
  color:#FFF;
  background:#EF6C00;
}
.page{
  margin-right: 10px;
}
.ranknum{
  font-weight: bold;
  color:#F92672;
}
#myrank{
  color: #FFF;
  font-weight:bold;
  background-color: #FBC853;
}
</style>
<script type="text/javascript">
</script>
<body>
<div class="top text-center">
  <div class="title">
    <a class="title_child <if condition='$type neq 1'>active</if>" href="{sh::U('User/ranklist', array('type' => 0))}">月排行</a>
    <a class="title_child <if condition='$type eq 1'>active</if>" href="{sh::U('User/ranklist', array('type' => 1))}">總排行</a>
  </div>
</div>
<div id="myrank" class="alert alert-danger text-center">
  我的商戶數(shù):{sh:$my_user_count} &nbsp;&nbsp; 當前排名: {sh:$my_rank}
</div>
<div id="datalist">
<table class="table table-hover">
   <thead>
    <tr>
     <th>&nbsp;&nbsp;#</th>
     <th>姓名</th>
     <th>商戶數(shù)</th>
    </tr>
   </thead>
   <tbody>
     <volist name="list" id="vo">
    <tr>
     <th scope="row" class="ranknum">
     <if condition="$vo.rank eq 1"><img src="{sh::RES}public/img/gold.png" >
     <elseif condition="$vo.rank eq 2"/><img src="{sh::RES}public/img/silver.png" >
     <elseif condition="$vo.rank eq 3"/><img src="{sh::RES}public/img/copper.png" >
     <else />
     &nbsp;&nbsp;{sh:$vo.rank}
     </if>
     </th>
     <td>{sh:$vo.name}</td>
     <td>{sh:$vo.usercount}</td>
    </tr>
    </volist>
   </tbody>
</table>
<div class="page text-right">
    {sh:$page}
</div>
</div>
</body>
</html>

php

// 排行榜
public function ranklist(){
    $type = $this->_get('type','trim');
    $this->assign('type',$type);
    $opener_id = $this->opener_id;
    if($type == 0){ // 上月排行
      $arrLastMonth = $this->getLastMonthStartEndDay();
      $lastStartDay = $arrLastMonth['lastStartDay'];
      $lastEndDay = $arrLastMonth['lastEndDay'].' 23:59:59'; 
      $b_time = strtotime($lastStartDay);
      $e_time = strtotime($lastEndDay);
      $where['b.addtime'] = array(array('gt',$b_time),array('lt',$e_time),'and'); 
    }
    $where['a.status'] = array('eq','1');
    M()->query('SET @rank =0;');
    $subQuery = M()->table('sh_opener a')->join('sh_user b on a.id = b.opener_id')->where($where)->group('a.id')->order('usercount desc')->field('a.id,count(b.id) as usercount,a.name')->select(false);
    $all = M()->table(''.$subQuery.' a')->getField('a.id,a.usercount,a.name,(@rank:=IFNULL(@rank,0)+1) as rank');
    $count   = count($all);
    $Page    = new Page($count, 10);
    $list    = M()->table('sh_opener a')->join('sh_user b on a.id = b.opener_id')->where($where)->group('a.id')->order('usercount desc')->limit($Page->firstRow.','.$Page->listRows)->field('count(b.id) as usercount,a.name,a.id')->select();
    foreach ($list as $k => $v) {
      $list[$k]['rank'] = $k + 1 + $Page->firstRow;
    }
    // 我的商戶
    $my_user_count = $all[$opener_id]['usercount']?$all[$opener_id]['usercount']:0;
    $my_rank = $all[$opener_id]['rank']?$all[$opener_id]['rank']:'-';
    $this->assign('my_user_count',$my_user_count);
    $this->assign('my_rank',$my_rank);
    $this->assign('page',$Page->show());
    $this->assign('list', $list);
    $this->display();
}
// 獲取上一月開始與結束日期
private function getLastMonthStartEndDay(){
    $thismonth = date('m');
    $thisyear = date('Y');
    if ($thismonth == 1) {
      $lastmonth = 12;
      $lastyear = $thisyear - 1;
    } else {
      $lastmonth = $thismonth - 1;
      $lastyear = $thisyear;
    }
    $lastStartDay = $lastyear . '-' . $lastmonth . '-1';
    $lastEndDay  = $lastyear . '-' . $lastmonth . '-' . date('t', strtotime($lastStartDay)); //t 給定月份所應有的天數(shù),28到31
    return array('lastStartDay'=>$lastStartDay,'lastEndDay'=>$lastEndDay);
}

這里用的是thinkphp的分頁類實現(xiàn)的。

案例效果

thinkPHP中怎么實現(xiàn)統(tǒng)計排行與分頁顯示功能

關于thinkPHP中怎么實現(xiàn)統(tǒng)計排行與分頁顯示功能問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關知識。

新聞標題:thinkPHP中怎么實現(xiàn)統(tǒng)計排行與分頁顯示功能-創(chuàng)新互聯(lián)
標題來源:http://www.aaarwkj.com/article12/ieegc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供云服務器、全網(wǎng)營銷推廣、移動網(wǎng)站建設響應式網(wǎng)站、品牌網(wǎng)站建設虛擬主機

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化
91黑丝国产在线播放| 午夜福利不卡片在线观看| 色哟哟网站一区二区精品久久 | 日本熟女肥臀一区二区| 欧美日韩午夜久久免费| 粉嫩av北条麻妃电影| 成人黄色三级免费网站| 好狼色欧美激情国产区| 日韩欧美一区二区三区| 美国一级黄片在线观看| 中文字幕欧美精品日韩人妻| 密臀精品国产一区二区| 亚洲欧美精品一区二区三区| 国产偷人伦激情在线观看| 久久精品国产一区二区三区91| 尤物欧美精品一区二区三区| 91国产精品视频在线| 亚洲综合日韩精品在线| 传媒视频免费在线观看| 人妻黄色这里只有精品| 欧美亚洲av一区二区三区| 热久久精品只有这里有| 最新国产激情福利网站| 久久超碰一区二区三区| 亚洲综合日韩欧美一区二区三区| 精品一区二区人妻乱交| 91精品国产人妻女教师| 日本一区中文字幕怎么用| 一区二区三区欧美日韩| 人人妻人人澡人人妻| 国产高清剧情av网站| 色吊丝日韩在线观看| 精品人妻一区二区四区| 日韩一区二区三区av观看| 国产一级成人免费视频| 免费观看毛片一区二区三区| 日韩不伦高清一区二区三区| 亚洲国产中文字幕高清| 欧美在线观看香蕉视频| 亚洲 综合 久久久| 国产一区二区三区av网站|