thinkphp實現資料分頁

來源:互聯網
上載者:User

標籤:

方法一:

 

 1 public function show_cate(){ 2          3         $category_name = array( 4             ‘1‘ => ‘政法綜治前沿‘, 5             ‘2‘ => ‘政策法規‘, 6             ‘3‘ => ‘平安建設‘, 7             ‘4‘ => ‘通知公告‘, 8             ‘5‘ => ‘理論研討‘, 9             ‘6‘ => ‘本地動態‘,10             ‘7‘ => ‘隊伍建設‘,11             );12         $category_id = I(‘get.category_id‘);13         $model = M(‘zx_article‘);14                                  //計算要顯示的總資料條數15         $count = $model->where(‘category_id =‘.$category_id)->order(‘article_id desc‘)->count();16                                 //執行個體化Page類,傳入總條數和每頁要顯示的條數17         $page = new \Think\Page($count,2);18                               //使用limit函數指定查詢和操作的數量19         $data = $model->where(‘category_id =‘.$category_id)->order(‘article_id desc‘)->limit($page->firstRow.‘,‘.$page->listRows)->select();20                                 //傳資料給模板21         $this->assign(‘data‘,$data);22                                //調用Page類的show()函數
23 $this->assign(‘page‘,$page->show());24 $this->assign(‘name‘,$category_name[$category_id]);25 $this->display();26 }

 

thinkphp實現資料分頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.