0
我經過一些幫助CodeIgniter分頁(修復一個錯誤)..我可以看到在視圖中的記錄數和分頁鏈接,但點擊下一個鏈接時,它不顯示下一個/上一個10記錄。有人可以幫助我嗎?CodeIgniter分頁
我有我的控制器
function customerlist_pagination()
{
$search = $this->input->post('search');
$data['title'] = "Customer Clist";
$data['heading'] = "List of customers";
$data['result'] = $this->customers_model->getAllcustomers_pagination($search_para, FALSE, "limit_rows");
$data['num_recs'] = $this->customers_model->getAllcustomers_pagination($search_para, FALSE, "num");
$config['base_url'] = base_url().'index.php/customer/customerlist_pagination/';
$config['total_rows'] = $data['num_recs'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['next_link'] = 'Next >';
$config['prev_link'] = '< Previous ';
$this->pagination->initialize($config);
$this->load->view('customer_view_table',$data);
}
在模型下面的代碼,我有以下代碼:
function getAllSeizures_pagination($search_para, $archive_search = FALSE, $result_type)
{
$search_para = $search_para."%";
$selected_fields = "customer.firstName
customer.lastName, customer.address,
customer.city, customer.postcode";
$from = "customer";
$where = "customer.deleted=0 ";
if ($archive_search == TRUE) {
$where .= "AND customer.archived= 1 ";
}else{
$where .= "AND customer.archived= 0 ";
}
$where .= "AND (customer.firstName LIKE '$search_para' OR customer.postcode LIKE '$search_para' OR customer.city LIKE '$search_para')";
$query = $this->db->select($selected_fields, false)
->from($from)
->where($where)
->order_by('customer.idcustomer', 'desc');
if($result_type == "limit_rows")
{
$query = $this->db->limit(10, 0)
->get();
$query = $query->result();
}
if($result_type == "num") {
$query = $this->db->get();
$query = $query->num_rows();
}
return $query;
}
非常感謝
問候 普拉斯
你噠你的記錄是多少算tabase表? – toopay
它返回25,這是所有記錄...和極限是10 – pks
那麼,那沒什麼不對。如果你想在你的分頁導航中顯示一個序列號,至少你必須有60個或更多的記錄,然後在你的分頁配置中添加'$ config ['num_links'] = 2;',一切都會像你想的那樣。 – toopay