我在控制器中有这个功能,它从模型中调用所有项目并在主页中进行分页,所以我调用主页如下:
http://localhost/cart/index.php/
当转到下一页时,显示此错误:
404 Page Not Found
我的控制器:-
public function index() {
$config = array();
$config["base_url"] = base_url() . "index.php";
$config["total_rows"] = $this->main_model->record_count();
$config["per_page"] = 8;
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data["home_products"] = $this->main_model->fetch_items($config["per_page"], $page);
$data["links"] = $this->pagination->create_links();
$data['categories'] = $this->main_model->getAllCategories();
$this->load->view("home", $data);
}
和模型:
public function record_count() {
return $this->db->count_all("wg_items");
}
public function fetch_items($limit, $start) {
$this->db->limit($limit, $start);
$query = $this->db->get("wg_items");
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
并查看:
<!-- Show pagination links -->
<p style="float:left"><?php echo $links; ?></p>
哪里出错了??