控制器:
function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->library('cart');
$this->load->database();
$this->load->model('user_model');
$this->load->library("pagination");
//$this->load->library('result/Apache/Solr/apache_solr_service');
$this->load->library('email');
}
public function index()
{
$config["base_url"] = base_url() . "index.php/index/index";
//print_r($config["base_url"]);
$config["total_rows"] = $this->user_model->record_count();
$limit = $config["per_page"] = 9;
$config["uri_segment"] = 2;
//$config['use_page_numbers'] = TRUE;
$data['count']= $this->user_model->record_count();
//print_r($data['count']);
$this->pagination->initialize($config);
$start = ($this->uri->segment(2))? $this->uri->segment(2) : 0;
$data["data"] = $this->user_model->product($limit,$start);
$data["links"] = $this->pagination->create_links();
print_r($data['links']);
print_r($data['data']);
//$this->load->view("pagination", $data);
//$this->load->view('inc/header');
//$data['data']=$this->user_model->product();
//$this->load->view('index',$data);
//$this->load->view('inc/footer');
}
型号:
public function product($limit, $start)
{
$this->db->select('*');
$this->db->order_by("id", "asc");
$this->db->limit($limit, $start);
$query=$this->db->get('newdeal');
return $query->result_array();
}
答案 0 :(得分:0)
正如Nouphal.M在评论中所说,改变
$config['uri_segment'] = 2;
到
$config['uri_segment'] = 3;
另外,作为旁注,您可以通过将其放入
来自动加载您的助手/库application > config > autoload.php
然后将库/助手放在正确的数组中。例如
$data['helper'] = array("url", "email", "form");