第一零五天上課 PHP TP架構下分頁

來源:互聯網
上載者:User

標籤:

控制器代碼(TestController.class.php)

<?phpnamespace Home\Controller;use Home\Controller\EmptyController;class TestController extends EmptyController{    public function test()    {        $user = D(‘User‘);        $count = $user->count();             //擷取資料總條數        $page = new \Think\Page($count,1);   //執行個體化分頁類        $page->setConfig(‘header‘,"共{$count}條資訊");                //配置分頁導覽列顯示的模組        $xianshi="共%TOTAL_ROW%條資料 共%TOTAL_PAGE%頁 %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%";        $page->setConfig(‘theme‘,$xianshi);  //配置分頁顯示模組        $page->setConfig(‘first‘,‘首頁‘);     //配置分頁單行資訊(首頁)        $page->setConfig(‘prev‘,‘上一頁‘);    //配置分頁單行資訊(上一頁)        $page->setConfig(‘next‘,‘下一頁‘);    //配置分頁單行資訊(下一頁)        $show = $page->show();               //擷取分頁導航資訊                //擷取分頁內容($page->firstRow 從第幾條開始)($page->listRows 每頁顯示幾條)        $list = $user->limit($page->firstRow,$page->listRows)->select();            $this->assign(‘list‘,$list);         //註冊變數        $this->assign(‘show‘,$show);         //註冊變數        $this->display();                     //調用模板    }     }

視圖代碼(Test/test.html)

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>分頁</title></head><body><table border="1"><tr>    <th>帳號</th>    <th>密碼</th>    <th>姓名</th>    <th>是否啟用</th></tr> <foreach name=‘list‘ item=‘i‘><tr>         <td><{$i[uid]}></td>     <td><{$i[pwd]}></td>      <td><{$i[name]}></td>      <td><{$i[isok]}></td>   </tr></foreach></table><{$show}>        //分頁導覽列</body></html>

 

第一零五天上課 PHP TP架構下分頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.