当我尝试访问下一页时遇到问题会发生的事情是它显示了codeigniter的错误404。我该如何解决这个问题?
控制器
//START OF PAGINATION
$this->load->library('pagination');
$table = "entries";
$config = array();
$config["base_url"] = base_url() . "entries/";
if(isset($_POST['event']) AND $_POST['event'] != "All"){
$where = "event = '$_POST[event]' AND deleted = 0";
$config["total_rows"] = $this -> entries_model -> count_filtered_entries($table,$where);
}
else{
$config["total_rows"] = $this -> entries_model -> count_entries($table);
}
$config["per_page"] = 10;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
echo "PAGE NUMBER ".$page;
if(isset($_POST['event']) AND $_POST['event'] != "All")
{
$where = "event = '$_POST[event]' AND deleted = 0";
$data["records"] = $this -> entries_model -> select_filtered_entries($config["per_page"], $page, $where);
}
else
{
$data["records"] = $this -> entries_model -> select_entries($config["per_page"], $page);
}
$data["records_links"] = $this->pagination->create_links();
$this->load->view('entries_index', $data);
答案 0 :(得分:0)
你的分页配置
$config["base_url"] = base_url() . "entries/";
和你的URI segemnt
$config["uri_segment"] = 3;
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
实际上t 这里只有一个URI段,所以改变就像这样
$config["uri_segment"] = 1;
$page = ($this->uri->segment(1)) ? $this->uri->segment(1) : 0;
答案 1 :(得分:0)
启用page_query_string
$this->load->library('pagination');
$config['base_url'] =base_url() . "entries?p=0";
$config['total_rows'] = 100;
$config['per_page'] = 10;
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
echo $this->pagination->create_links();
答案 2 :(得分:0)
通过将base_url
更改为$config["base_url"] = site_url('entries/index');
来解决此问题因为我的分页是在控制器的索引上。