问题
my controller page
public function index() {
$data['error']="";
$data['h']="";
$this->load->library('pagination');
$config['base_url'] = base_url().'Imagec/index';
$config['total_rows'] = 10;
$config['per_page'] = 2;
$config["uri_segment"] = 4;
$this->pagination->initialize($config);
$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data['h']=$this->Inserts_model->select($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$this->load->view('select_view', $data);
} my mode page
public function select($limit, $start)
{
$this->db->limit($limit, $start);
$query = $this->db->get('student');
return $query->result();
}
my view page
<p><?php echo $links; ?></p>
here all my code here when click on links the NOT FOUND error occur's
回答1:
Try this 100% will work
Controller :
public function index() {
$data['error'] = "";
$data['h'] = "";
$this->load->library('pagination');
$data['h'] = $this->inserts_model->select();
$config['base_url'] = base_url() . '/index.php/imagec/index';
$config['total_rows'] = count($data['h']);//it will give you total no of records
$config['per_page'] = 2;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['h'] = $this->inserts_model->select($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
// echo "<pre>";print_r($data);die;
$this->load->view('select_view', $data);
}
Model :
public function select($limit=0, $start=0) {
if (empty($start) && !empty($limit)) {
$this->db->limit($limit);
}
if (!empty($start) && !empty($limit)) {
$this->db->limit($limit, $start);
}
$query = $this->db->get('student');
return $query->result();
}
来源:https://stackoverflow.com/questions/46112609/pagination-not-working-in-codeigniter