thinkphp 帶檢索參數分頁

來源:互聯網
上載者:User

標籤:splay   xtend   檔案   顯示   function   hid   isp   use   dmi   

模板檔案中,提交搜尋內容要用get方法,同時設定g、m、c隱藏欄位。

<form action="{:U(‘Sck/qbscHjsc‘)}" method="get">    <table class="search-tab">    <tr>                    <input type="hidden" name="g" value="<?php echo MODULE_NAME; ?>">                    <input type="hidden" name="m" value="<?php echo CONTROLLER_NAME; ?>">                    <input type="hidden" name="a" value="<?php echo ACTION_NAME; ?>">                    <th width="120">素材名稱:</th>        <td>        <input class="common-text" name="mingcheng" size="20" value="" type="text">        </td>

 

controller中處理

// 素材庫 環境素材檢索public function qbscHjsc(){    $where = ‘ fenxiang=1 ‘;    // 查詢參數    if(I(‘request.leixing‘)!=‘‘){        if(I(‘request.mingcheng‘) != ‘‘){            $where .= ‘ and mingcheng like \‘%‘.I(‘request.mingcheng‘).‘%\‘ ‘;        }    }     ...    $sck_model=M("Kczz_sck");        $count=$sck_model->where($where)->count();    $page = $this->page($count, 10);    $list = $sck_model    ->where($where)    ->order("id desc")    ->limit($page->firstRow . ‘,‘ . $page->listRows)    ->select();    $this->assign(‘list‘, $list);    $this->assign(‘page‘, $page->show(‘Admin‘));    $this->display();}

 

如果是前台的controller,需要自己匯入page類

<?phpnamespace Home\Controller;use Think\Controller;class IndexController extends Controller {    public function sck(){        $where = ‘ fenxiang=1 ‘;        // 查詢參數        if(I(‘request.leixing‘)!=‘‘){            if(I(‘request.mingcheng‘) != ‘‘){                $where .= ‘ and mingcheng like \‘%‘.I(‘request.mingcheng‘).‘%\‘ ‘;            }        }         ...        $sck_model=M("Kczz_sck");        import(‘ORG.Util.Page‘);    // 匯入分頁類        $count=$sck_model->where($where)->count();            $Page = new \Think\Page($count,5);        $show = $Page->show();    // 分頁顯示輸出        $list = $sck_model        ->where($where)        ->order("id desc")        ->limit($Page->firstRow . ‘,‘ . $Page->listRows)        ->select();        $this->assign(‘list‘, $list);        $this->assign(‘page‘, $show);        $this->display();    }}

 

模板處翻頁代碼

<div class="list-page"> {$page}</div>

 

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.