分页首页在CI3中不起作用

问题描述

Route : $route['product/(:num)']  ='product/product';

Controller :   function index()
   {
     
    $this->load->helper(array('form','url','common'));
       
    $this->load->library(array('session','pagination','cart'));

    $this->load->model('productsdisplay','',true);
  

    $data['title'] = "Product || Adis Farms India";
    $data['meta_title'] = "Product  || Adis Farms India";
    $data['meta_description'] ="Product || Adis Farms India";

    $config = array();
    $config["base_url"] = base_url() . "product/1";
    $config["total_rows"] = $this->productsdisplay->get_count();
    $config["per_page"] = 2;
    $config["uri_segment"] = 2;

    $choice = $config["total_rows"] / $config["per_page"];
    $config["num_links"] = round($choice);

    $this->pagination->initialize($config);

    $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;

    $data["links"] = $this->pagination->create_links();

    $data['products'] = $this->productsdisplay->get_products($config["per_page"],$page);

   
    $this->load->view('inc/header',$data);
    $this->load->view('product/index',$data);
    $this->load->view('inc/footer',$data);

   }


Model : <?php
class Productsdisplay extends CI_Model
{
    function __construct()
    {
        parent::__construct();
         $this->load->database();
        $this->table_name = 'product';
    }
   
  
   function get_products($limit,$start)
    {
        $this->db->select('*');
        $this->db->select('product.id');
        $this->db->select('product_images.features');
        $this->db->from('product');
        $this->db->join('product_images',"product.id=product_images.product_id and product_images.features='yes'");
        $this->db->where("product.status='active'");
        $this->db->limit($limit,$start);
        // $this->db->order_by("product.product_name",$sort);
        $query = $this->db->get(); 
        return $query->result();
    }
    function get_details($id){
        $this->db->select('product.*');
        $this->db->select('product_images.image');
        $this->db->from('product');
        $this->db->join('product_images',"product.id=product_images.product_id and product_images.features='yes'");
        $this->db->where('product.id',$id);
        $this->db->where('product_images.product_id',$id);
        $query = $this->db->get(); 
        return $query->result();
    }

    function get_count() {
        return $this->db->count_all('product');
    }
   
 
}   

当我打开链接产品时,它显示404错误。当我打开链接/ product / 1时,它可以工作。请帮助我解决此问题。为什么CI项目中会出现此问题。我还有一个问题,在视图底部有一个下拉菜单,其中有两个选项分别为12和24,分页如何随着按值排序而动态变化。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...