php - Pagination in codeigniter. Extra set of values passed in to model and db->limit not working -
pagination in codeigniter. can't seem set limit of posts on every page (it shows of them on every page). think links working (they show on uri), not select rows per page.
the model:
public function index( $limit,$start, $var1,$var2,$var3,$var4 ){ $sql = "select trabalho.var1 trabalho.var2 empregos.var3 empregos.var4 trabalho.empregos join trabalho.empresas on empregos.id_empresa = empresas.id_empresa trabalho.var1 ? or trabalho.var2 ? or empregos.var3 ? or empregos.var4 ? ;"; $variables_form = array($var1,$var2,$var3,$var4); $this->db->limit($limit, $start); $query2 = $this->db->query($sql,$variables_form); return $query2->result(); }
the controller:
$config['base_url'] = base_url().'index.php/main_controller/index'; $config['total_rows'] = 10; $config['per_page'] = 5; $config['num_links'] = 2; $config["uri_segment"] = 3; $config['use_page_numbers'] = true; $this->pagination->initialize($config); $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $data["info"] = $this->search_display_m-> index($config["per_page"], $page, $var1 = 'a', $var2 = 'a', $var3 = 'a', $var4 = 'a', ); $data["links"] = $this->pagination->create_links();
and view:
<?php echo $this->pagination->create_links(); ?>
and there way simplify uri?
this work
public function index( $limit,$start, $var1,$var2,$var3,$var4 ){ $sql = "select trabalho.var1 trabalho.var2 empregos.var3 empregos.var4 trabalho.empregos join trabalho.empresas on empregos.id_empresa = empresas.id_empresa trabalho.var1 ? or trabalho.var2 ? or empregos.var3 ? or empregos.var4 ? limit $start, $limit ;"; $variables_form = array($var1,$var2,$var3,$var4); $query2 = $this->db->query($sql,$variables_form); return $query2->result(); }
Comments
Post a Comment