我已经按照步骤和教程进行操作了。但它不起作用。 我已经逐步从互联网上学习教程。但是当我进入第二页时,它总是显示404页面未找到
这是我的控制者:
public function index()
{
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/blog';
$config['uri_segment'] = 2;
$config['per_page'] = 2;
$config['total_rows'] = $this->mod_blog->getAllData()->num_rows();
$this->pagination->initialize($config);
// $page = ($this->uri->segment(2)) ? ($this->uri->segment(2) - 1) : 0;
$page = $this->uri->segment(2);
$data = array(
'data' => $this->mod_blog->getData($config['per_page'],$page)->result(),
'pagination' => $this->pagination->create_links()
);
$this->load->view('layout/header');
$this->load->view('layout/sidebar');
$this->load->view('admin/blog',$data);
$this->load->view('layout/footer');
}
这是我的模特:
function getData($limit,$start){
$this->db->select('*');
$this->db->from('berita');
$this->db->join('admin','admin.id_admin = berita.id_admin');
$this->db->limit($limit,$start);
$this->db->order_by('id_berita','desc');
return $this->db->get();
}
function getAllData(){
$this->db->select('*');
$this->db->from('berita');
$this->db->join('admin','admin.id_admin = berita.id_admin');
$this->db->order_by('id_berita','desc');
return $this->db->get();
}
答案 0 :(得分:0)
$config['base_url'] = base_url().'index.php/blog/index';
您必须将config [' base_url']指向您的baseUrl / controllerName / functionName。所以,我改成了。
$config['uri_segment'] = 3;
$page = $this->uri->segment(3);
然后我将我的Uri片段调整为3
{{1}}