CI框架分頁類的使用 1

2021-07-11 14:19:33 字數 902 閱讀 7432

首先,要查詢資料庫,確定一共有多少條資料

$this->load->model('test_model');

$user=$this->test_model->user_select_all();

$pageall=count($user);//總條數

$pagenum=20;//每頁顯示的條數

其次,進行config的配置

$config['total_rows']=$pageall;

$config['per_page']=$pagenum;

$config['num_links']=3;//定義當前頁面的前後各有幾個數字鏈結

$config['use_page_numbers']=true;//url中的數字顯示第幾頁,否則,顯示到達第幾條

最後,載入分頁類,並呼叫

$this->load->library("pagination");//載入

$this->pagination->initialize($config);//初始化配置

echo $this->pagination->create_links();//顯示<1 2 3 4.....>這樣的頁數選擇

echo "

";$id=$id?$id:1;

$start=($id-1)*$pagenum;

$list=$this->test_model->user_select_limit($start,$pagenum);//每一頁的內容

var_dump($list);

CI框架分頁類新增每頁條數選擇

ci框架分頁類如下圖所示,並沒有提供每頁條數的選擇,現在後台管理員說要加,你加還是不加呢 加它!加完效果如下圖所示,用cookie儲存每頁條數,預設是每頁10條 config.php中新增分頁條數配置 分頁記錄數 config page size array 10,30,50 constants.p...

CI框架增加條件搜尋,分頁

在網上找了半天,沒有乙個能寫明白的,到的怎麼使用帶條件分頁,我這裡用簡單說明實現它!1.使用ci框架分頁類,如果帶搜尋條件,首先要可以接收搜尋內容 cateid this input get post select cate searchkey this input get post searchk...

CI分頁類Controller樣例

controller層 this load library pagination 載入分頁類 config base url site url admin etp list 指向你的分頁所在的控制器類 方法的完整的 url 分頁鏈結跳轉的方法 config total rows count this...