Pagination |
[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.
[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';
[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 Now works fine.
[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
[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
[eluser]Unknown[/eluser]
If you load the models seperate lik: Code: $this->load->model('Novosti_Model'); Does is it work then? |
Welcome Guest, Not a member yet? Register Sign In |