I\'m trying to use codeigniter pagination for my products so there are multiple pages which products but its not working for me and I don\'t know why..
This is my pagina
You have a mix of code, pagination and not pagination results.
Add,
$config["num_links"] = 5; //Number of links in pagination
After initilize Codeigniter pagination library. You have to execute a pagination query in your database, for example:
$where = "IF you have got";
$orderby "IF you have got";
$data['products'] = $this->Pagination_model->select_products($config["per_page"], $this->uri->segment(3), $where, $orderby);
Then in your model Pagination_model, you should have got this:
public function select_products($per_page, $segment, $where, $orderby)
{
if (!isset($segment)) $segment = 1;
$init= ($segment - 1) * $per_page;
$sql = "SELECT *
FROM Your_table
$where
ORDER BY $orderby
OFFSET $init ROWS
FETCH NEXT $per_page ROWS ONLY";
$query= $this->db->query($sql);
return $query->result_array();
}
Be sure you are right point to this->uri->segment() is 3. I think you dont have pagination links because you dont have results in your query.