Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.