![]() |
Pagination - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Pagination (/showthread.php?tid=39888) |
Pagination - El Forum - 03-23-2011 [eluser]kr1pt[/eluser] Model: Code: <?php And controller: Code: <?php My pagination does not work. When I go to: http://localhost/zabavnjak/novosti/1 I get Code: 404 Page Not Found I've got only 2 rows in db so I put 1 per page. Pagination - El Forum - 03-24-2011 [eluser]Talifhani[/eluser] Try watch this http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-7-pagination/ Pagination - El Forum - 03-24-2011 [eluser]kr1pt[/eluser] I do the same as him, but still 404. Pagination - El Forum - 03-24-2011 [eluser]Talifhani[/eluser] oh sorry didnt really look. Try do change this: $config['base_url'] = base_url(). 'novosti/'; To this: $config['base_url'] = base_url(). 'novosti/page'; Pagination - El Forum - 03-24-2011 [eluser]kr1pt[/eluser] Still nothing. Code: $redovi = $this->db->order_by('id', 'DESC')->get_where('novosti', array('status' => 'aktivno'))->num_rows(); Why I get 404? :S And in second pagination everything works fine... I just copied code from other pagination and I still get 404. EDITED: I can't use pagination in index() method obviously ![]() Pagination - El Forum - 03-25-2011 [eluser]Talifhani[/eluser] haha, silly rabit. I didnt even catch that. Good luck. Also, i think you can if you specify $config['base_url'] = base_url() . 'novosti/index/'; havent tried but, im sure you can. Almost Pagination - El Forum - 03-25-2011 [eluser]smartweb[/eluser] Change router.php Pagination - El Forum - 03-29-2011 [eluser]Reneesh T K[/eluser] I am here including a sample of how my pagination function looks and works for me: in controller file: function index(){ $configs['base_url'] = base_url()."customer_controller/index/"; $configs['per_page'] = '25'; $configs['num_links'] = 4; $configs['prev_link'] = '«Previous'; $configs['next_link'] = 'Next»'; $configs['anchor_class'] = ' class="number" '; $configs['cur_tag_open'] = ' <a class="number current">'; $configs['cur_tag_close'] = '</a>'; $configs['total_rows'] = $this->customer_model->getSiteUsers(); $this->pagination->initialize($configs); $current_page = $this->uri->segment(3); $current_page = ($current_page/$configs['per_page']) + 1; $total_pages = ceil($configs['total_rows']/$configs['per_page']); $data['page_info'] = "Page ( $current_page of $total_pages )"; $data['result'] = $this->customer_model->getSiteUsers($configs['per_page'],$this->uri->segment(3)); $data['pagination'] = $this->pagination->create_links(); $this->load->view('main.php',$data); } In Model: function getSiteUsers($num=0,$offset=0) { $limit = ""; if($offset =="") $offset =0; if($num !=0){ $limit = " limit $offset , $num "; } $query = "SELECT * from customers $limit"; $result = $this->db->query($query); if($limit=="") return $result->num_rows(); else return $result->result_array(); } In View : <div class="pagination"><? echo $page_info; ?> <?php echo $pagination;?></div> Hope this is clear ![]() Pagination - El Forum - 03-29-2011 [eluser]Unknown[/eluser] If you load the models seperate lik: Code: $this->load->model('Novosti_Model'); Does is it work then? |