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

[eluser]feri_soft[/eluser]
I have a recursive function for getting all products in the cat and in its subcats and its working fine:

Code:
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.

Code:
$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...
#2

[eluser]feri_soft[/eluser]
Any ideas? This is something that is very important.
#3

[eluser]ecsyle31[/eluser]
Is that the exact code that is giving you errors?
Code:
$this->db->getAllproducts($cat_info['$id'], $config['per_page'], $this->uri->segment(3));
Try removing the single quotes around $id in $cat_info['$id'].

What is the exact error you are getting?
#4

[eluser]feri_soft[/eluser]
Well i just dont get the right pagination. Some pages have products others dont, or product number is not correct. I know from the db that i should have 10 products but only some appear for example.




Theme © iAndrew 2016 - Forum software by © MyBB