php - error with pagination codeigniter -
i have problem pagination in codeigniter. when click page two, information loaded. page active one, not two. can me??
this code:
in config pagination
$config['pagination']['full_tag_open']='<div class="row"><div class="col-xs-12"><div class="datatables_paginate paging_bootstrap"><ul class="pagination pull-right">'; $config['pagination']['full_tag_close']='</ul></div></div></div>'; $config['pagination']['first_link']='← trang đầu'; $config['pagination']['first_tag_open']='<li class="prev disabled">'; $config['pagination']['first_tag_close']='</li>'; $config['pagination']['last_link']='trang cuối'; $config['pagination']['last_tag_open']='<li>'; $config['pagination']['last_tag_close']='</li>'; $config['pagination']['next_link']='trang sau → '; $config['pagination']['next_tag_open']='<li class="next">'; $config['pagination']['next_tag_close']='</li>'; $config['pagination']['prev_link']='← trang trước'; $config['pagination']['prev_tag_open']='<li class="prev">'; $config['pagination']['pre_tag_close']='</li>'; $config['pagination']['cur_tag_open']='<li class="active"><a>'; $config['pagination']['cur_tag_close']='</a></li>'; $config['pagination']['num_tag_open']='<li>'; $config['pagination']['num_tag_close']='</li>'; $config['pagination']['use_page_numbers'] = true; $config['pagination']['per_page'] = 5; $config['pagination']['num_link']=7; $config['pagination']['uri_segment']=4;
and in controller
$this->load->library('pagination'); $config = $this->config->item('pagination'); $config['base_url'] = $this->config->base_url('admin/posts/view'); $config['total_rows'] = $this->model_posts->total(array('site_id'=>$this->site_id)); $total_page=ceil($config['total_rows']/$config['per_page']); $page = ($page>$total_page)?$total_page:$page; $page = ($page<1)?1:$page; $page = $page-1; $config['pagination']['cur_page'] = $page; $this->pagination->initialize($config); $data['list_paginition'] = $this->pagination->create_links(); if($config['total_rows']>0){ $data['list_posts'] = $this->model_posts->view(($page*$config['per_page']),$config['per_page']); }
and in model
public function view($start,$limit){ return $this->db->select('utt_post.id,utt_post.title,utt_post.description,utt_post.detail,utt_post.image,utt_post.status,utt_post.time_create,utt_post.time_update,utt_cate.title catetitle,utt_users.username')->from('utt_post')->join('utt_users','utt_users.id = utt_post.user_id')->join('utt_cate','utt_cate.id = utt_post.cate_id')->where('utt_post.status < ','3')->where('utt_post.status > ','0')->where('post_type','news')->where('utt_post.site_id = ',$this->site_id)->order_by('utt_post.id desc')->limit($limit,$start)->get()->result_array();}
Comments
Post a Comment