Jump to content

Pagination problem


feri_soft

Recommended Posts

Hi all,

I am using Codeigniter here but thats not the problem 100% i just need some php/mysql advice.

 

I have a recursive function for getting all products in the cat and in its subcats and its working fine:

 

	function getAllProducts($catID, $limit, $offset){
	$query = $this->db->getwhere('products',array('category' => $catID), $limit, $offset);
	if($query->num_rows() > 0){
		foreach($query->result_array() as $product){
		$this->products[] = $product;
		}
		}
		if($this->getSubCats($catID)){
			foreach ($this->getSubCats($catID) as $subcat) {
				$this->getAllProducts($subcat['id'], $limit, $offset);
                }
		}
	return $this->products;
}

 

Now i can put the total_results, the url and so on in the pagination config, but when i try to manipulate the limit and offset in this function i get errors.

 

$this->db->getAllproducts($cat_info['$id'], $config['per_page'], $this->uri->segment(3));

 

How am i supposed to change the function so that the correct articles are get. Now i get all on the first page and nothing on the rest...

 

uri->segment is identical to $_GET[].... in a way

Link to comment
https://forums.phpfreaks.com/topic/74995-pagination-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.