-
Beginner
Pagination Function
PAGINATION FUNCTION
This a pagination function that makes the presentation of the total list of available pages much cleaner and user-friendly.
Features
- can be used anywhere in your game
- ability to customize how many pages are displayed in the spread
- CSS styled pagination elements
- First Page and Last Page buttons
How to Use
The pagination function calls for 5 arguments; $total, $action, $page, $perpage, $spread.
- $total: the total number of entries to use in your pagination. Ex. If this function was used for your events, you would need to send in the total number of events for the given user.
- $action: the function requires you to use a $_GET action parameter to send the user back to the correct page. If you are using a different parameter, or not using a parameter at all, the function can be easily modified to accomodate
- $page: what page the user is currently on
- $perpage: how many instances you want to display (default 25)
- $spread: the maximum number of pages you want to show between the first and last button (default 5)
The function will print out the page list.The function will return the value of the current page that you are on, so that you can use it in your query.
(Example of using the function: Events page)
The returned value will be whatever page the user is currently on multiplied by the total number of events per page. This will be used as the starting value for the LIMIT in our query.
Function Code
PHP code:
CSS code:
-
Beginner
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks