• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination 404, can someone help please!

#1
[eluser]ppwalks[/eluser]
I am trying to paginate a record set in an admin panel, the url is http://localhost/mydomain/admin/products. the links show up correctly but when I click the link it gives me a 404.

Here is my code:

Model

Code:
function get_admin_products() {
   $result = $this->db->query("SELECT p.product_id, p.product_name, p.price, GROUP_CONCAT( DISTINCT (
    pc.category_id
    ) ) AS category_ids, GROUP_CONCAT( DISTINCT (
    c.name
    ) ) AS category_names
    FROM product AS p
    LEFT JOIN product_category AS pc
    USING (
    product_id
     )
    LEFT JOIN category AS c
    USING (
    category_id
    )
    GROUP BY product_id");
    return $result->result_array();
}
Controller

Code:
function index() {
  $data['admin_title']= "";
  $data['folder']= "products";
  $data['main']= "products_view";
  $admin_products = $this->MProducts->get_admin_products();
   $quantity = 15; // how many per page
    $start = $this->uri->segment(3); // this is auto-incremented by the pagination class
     if(!$start) $start = 0;    
     $data['admin_products'] = array_slice($admin_products, $start, $quantity);
     $config['base_url'] = base_url().'admin/products';
     $config['uri_segment'] = 3;
     $config['total_rows'] = count($admin_products);
     $config['per_page'] = $quantity;
     $this->pagination->initialize($config);

  $data['pagination'] = $this->pagination->create_links();
  $data['get_last'] = $this->MProducts->get_last_product_id();
  $data['build_categories'] = $this->MProducts->get_all_categories();
        $this->load->view('admin/user_view', $data);
}

If someone could please help it would be much appreciated..

Thanks

Paul


Messages In This Thread
Pagination 404, can someone help please! - by El Forum - 08-07-2012, 04:16 AM
Pagination 404, can someone help please! - by El Forum - 08-07-2012, 09:45 PM
Pagination 404, can someone help please! - by El Forum - 08-08-2012, 06:34 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.