Php codeigniter中的分页未按预期工作
我的控制器Php codeigniter中的分页未按预期工作,php,codeigniter,Php,Codeigniter,我的控制器 function index() { $this->load->library('pagination'); $this->load->model('specialoffer_model'); if($this->input->post('btnUpdate')) { $this->specialoffer_model->addoffer(); } $data['addof
function index()
{
$this->load->library('pagination');
$this->load->model('specialoffer_model');
if($this->input->post('btnUpdate'))
{
$this->specialoffer_model->addoffer();
}
$data['addoffer']=$this->specialoffer_model->addoffer();
$data1=array(
'row'=>$data['addoffer']['row'],
'result'=>$data['addoffer']['result'],
);
$config['base_url'] = site_url('specialoffer/index') . '/';
$config['total_rows'] = $this->db->count_all('home');
$config['per_page'] =2;
$this->pagination->initialize($config);
$data1['results'] =
$this->specialoffer_model->get_page (
$config['per_page'],
$this->uri->segment(3));
$this->load->view('specialoffer',$data1);
}
看法
只生成页面链接,点击页面会刷新页面,但会显示表中的所有记录,而我已经指定了表中的2条记录要显示。简而言之,分页不起作用。帮助最好使用:
$this->db->limit($num,$offset);
$query = $this->db->get('home');
return $query->row_array();
请提供任何建议或建议这是紧急的请发布您的模型代码我很确定您没有在您的查询函数get_页面中使用offset和limit子句($num,$offset){$query=$this->db->get('home',$num,$offset);return$query;}试试这个。。。返回$query->result_array();
$this->db->limit($num,$offset);
$query = $this->db->get('home');
return $query->row_array();