Welcome Guest, Not a member yet? Register   Sign In
pagination problem
#1

[eluser]elombashy[/eluser]
hii..
here is my pagination config..:

//controller
function getProducts($id){
$this->load->library('pagination');
$config['total_rows'] = $this->common->getNumProducts($id); //gets 34
$config['base_url'] = base_url().'/main/getProducts/'.$id.'/';
$limit=15;
$config['per_page'] = $limit;
$config['num_links'] = 5;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';

$this->pagination->initialize($config);

$data3['products']=$this->common->getProductsPerSubcategory($id,$limit);
}

//model

function getProductsPerSubcategory($id,$limit){
$lang_sql=$this->session->userdata('lang_sql');
$data=array();
$this->db->select('product.product_id, model, product.image AS image, price, name')->from('product')
->join('product_to_category','product_to_category.product_id=product.product_id')
->join('product_description','product_description.product_id=product.product_id')
->where('product_to_category.category_id',$id)->where('language_id',$lang_sql)
->limit($limit);
$q=$this->db->get('',$limit, $this->uri->segment(4));
if($q->num_rows()>0){
foreach($q->result_array() AS $row){
$data[]=$row;
}
}
return $data;
}



I used the same configs on the search function and it worked..
the only deffirence i could notice is that in search function the segment url of the limit is 3. here it's 4.

any ideas?
#2

[eluser]osci[/eluser]
you need
Code:
$config['uri_segment'] = 4;

check the user guide




Theme © iAndrew 2016 - Forum software by © MyBB