[solved] Pagination + multiple segments |
[eluser]Unknown[/eluser]
greetings, im new to ci and an im having an issue with pagination when im using segments for exemple http://mysite.com/index.php/product/index/type/category. the problem is that the links are stuck at number 1 and wont change. please give a look at the code. a want to paginate only the items that match the criteria passed through the url. ### the menu for choosing products is something like this. <?php echo anchor('product/index/type1/cat2/','calculators'); ?> <?php echo anchor('product/index/type3/cat5/','pencils'); ?> ###controller public function index($tipo,$cat,$row = 0) { $this->load->library('pagination'); $this->load->model('produtos_model'); $config['base_url']= 'http://localhost/CodeIgniter/index.php/prod/product/'.$tipo.'/'.$cat.'/'; $config['total_rows'] = 20; $config['per_page'] = 6; $this->pagination->initialize($config); $data['dados'] = $this->produtos_model->pega_produtos($tipo,$cat,$row); $data['links'] = $this->pagination->create_links(); $data['conteudo'] = $this->load->view('produtos',$data,TRUE); $this->load->vars($data); $this->load->view('master_page'); } ###model public function pega_produtos($tipo,$cat,$row) { if ($cat != 0) { $query = $this->db->query("SELECT * FROM produto WHERE idtipo = '$tipo' and idcategoria = '$cat' ORDER BY codigo LIMIT $row,6"); foreach ($query->result_array() as $row) { $data[] = $row; } } return $data; }
[eluser]jcavard[/eluser]
This is probably the setting that is missing in your code: Code: $config['uri_segment'] = 5; HTH
|
Welcome Guest, Not a member yet? Register Sign In |