Welcome Guest, Not a member yet? Register   Sign In
CI Pagination Helper
#1

[eluser]ray73864[/eluser]
I must be thick or something as i can't seem to get the pagination helper to work, mind you, the user guide is very vague on how to make it work too.

This is the function i am trying to paginate (i haven't started using models yet, so it is a bit long):

Code:
function products($categoryid = 0, $page = 10)
    {        
        $this->db->select(' product.id AS product_id,
                            product.name AS product_name,
                            product.description AS product_description,
                            product_code,
                            category.id AS category_id,
                            category.name AS category_name');
        $this->db->from('product');
        $this->db->join('category','category.id = product.cat_id','left outer');
        $this->db->where('product_code != ','');
        $this->db->where('inactive',0);
        
        if ($categoryid)
        {
            $data['category_id'] = $categoryid;
            $this->db->where('category.id',$categoryid);
        } else {
            $data['category_id'] = 0;
        }
        
        $this->db->limit($page);
        
        $this->db->order_by('product_code','asc');

        $query = $this->db->get();
        
        $this->load->library('pagination');

        $config['base_url'] = 'http://capelite.rayherring.net/admin_catalogue/products/';
        $config['total_rows'] = $query->num_rows();
        $config['per_page'] = '10';
        $config['uri_segment'] = '4';

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

        $data['links'] = $this->pagination->create_links();
        
        $data['categoryid'] = $categoryid;
        $data['result'] = $query;
        $this->load->view('header', $this->settings);
        $this->load->view('shop_bar');
        $this->load->view('menu');
        $this->load->view($this->catalogue_folder . 'product/list', $data);
        $this->load->view('footer');
    }

and in my view i am doing: <?= $links; ?>

I have almost 5000 records in the database table, and removing the limit causes the browser to hang, so i really need the pagination to work.


Messages In This Thread
CI Pagination Helper - by El Forum - 09-28-2008, 12:33 AM
CI Pagination Helper - by El Forum - 09-28-2008, 12:51 AM
CI Pagination Helper - by El Forum - 09-28-2008, 01:08 AM
CI Pagination Helper - by El Forum - 09-28-2008, 01:11 AM
CI Pagination Helper - by El Forum - 09-28-2008, 02:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB