![]() |
Problem in Pagination - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Problem in Pagination (/showthread.php?tid=20043) |
Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] Hey guys i am doing pagination and i am unable to resolve this thing. I am getting the value of $this->uri->segment(4) for my offset but it returns nothing. class Users extends Controller { function Users(){ parent::Controller(); $this->load->model('usermodel'); $this->load->library('pagination'); $this->load->library('session'); $this->load->helper('url'); $this->load->helper('form'); $this->load->helper('date'); $this->load->library('validation'); $this->load->library('email'); } function users_view(){ /// set page title $this->data['title'] = 'View Users Records '; $this->load->vars($this->data); /******Paginating Records********/ $rows=$this->db->count_all("tms_user"); $base=base_url(); $config['base_url'] =base_url().$this->config->item('index_page').'/'.'users/users_view'; $config['total_rows'] = $rows; $config['per_page'] = '5'; $config['uri_segment'] = 4; $config['num_links'] = 4; $config['first_link'] = '«'; $config['last_link'] = '»'; $config['next_link'] = '>'; $config['prev_link'] = '<'; $this->pagination->initialize($config); /*******************************/ $data=$this->load_leftmenu(); $user_id = $_SESSION['user_id']; $data['alluserList'] = $this->usermodel->get_all_user($config['per_page'],$this->uri->segment(4),$user_id); // $this->load->view('users_view',$data); exit; } A Database Error Occurred SELECT * from tms_user where userId <> 1 and deleted='0' order by username LIMIT 5, Regards, Thanx in advance..... Problem in Pagination - El Forum - 06-26-2009 [eluser]Thorpe Obazee[/eluser] [quote author="zombica" date="1246014496"] Code: $config['base_url'] =base_url().$this->config->item('index_page').'/'.'users/users_view' it could be easier to just use. site_url('users/users_view'); Anyway, try $this->uri->segment(3) here Code: $data[‘alluserList’] = $this->usermodel->get_all_user($config[‘per_page’],$this->uri->segment(4),$user_id); Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] Thanx... Buddy you there again for resolving my problem. Hey man this doesn't affect any thing same DB error showing nothing for offset. Problem in Pagination - El Forum - 06-26-2009 [eluser]Thorpe Obazee[/eluser] Code: $config[‘uri_segment’] = 4; Is there any reason why you're using segment 4? It seems that the segment should be 3. Are you using routing? Can you show get_all_user() from the model? Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] Here it goes.... //Get All users data function get_all_user($num,$offset,$user_id) { $query = $this->db->query("SELECT * from tms_user where userId <> $user_id and deleted='0' order by username LIMIT ".$num.",".$offset." "); $result=$query->result(); return $result; } Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] No i can use $this->uri->segment(3) .. i am not using any kind of routing. I have done this by both 3 and 4. It doesn't affects. Problem in Pagination - El Forum - 06-26-2009 [eluser]Thorpe Obazee[/eluser] Try using the AR. I assume the problem occurs on the first page only. Nothing is preventing the ',' comma from getting in your query which causes the error. Code: $this->db->where(array('userId' <> =>$user_id, 'deleted' => 0)); Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] Yes problem is with only the first page it does not comes once we are in some inner page. Giving parse error on this line.... $this->db->where(array('userId' <> =>$user_id, 'deleted' => 0)); Problem in Pagination - El Forum - 06-26-2009 [eluser]zombica[/eluser] Thanx it resolve. Thanx buddy a lot. |