The Pagination class is one that always gives me trouble when using someone else's code. I've created this class and hopefully have documented it enough for you to jump right into it.
And here's the pagination class itself:
All you'll need to do is add the following code to the class that you're using:
- Instantiate the Pagination class
- Add the $per_page variable and set it to how-many you want to display per pag.
- i.e. $per_pag = 20;
- Call the getStartAt() method to create the int from where the sql query will begin. This is the query that calls your items to be displayed to the page and really has nothing more to do with the rest of the pagination: $start_at = $this->_pagination_obj->getStartAt($per_page);
- $sql = "SELECT vehicle, image FROM customer_rides WHERE approved = '1'";
- $sql .= " AND brand = 'XX'";
- $sql .= " LIMIT $start_at, $per_page";
- At the end of the code, you'll need to call the createPageNumbers() method and pass the sql code to select the number of rows that are active in that table.
- $sql = "SELECT id FROM customer_rides WHERE approved = '1' AND brand = 'XX'";
- $this->_pagination_obj->createPageNumbers($sql);
The first class is the PaginationExample. Quite a significant amount of code has been deleted from the class and the method displayCustomerRides() so that the pagination can easily be followed.
And here's the pagination class itself:
Comments
Post a Comment