Jump to content
MakeWebGames

Pagination Function


Recommended Posts

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)

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

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:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

CSS code:

[CSS]

.pagelist {

border: 1px solid #444444;

padding: 2px 6px;

text-decoration: none;

font-size:12px;

}

[/CSS]

Link to post
Share on other sites
  • 10 years later...

Just adding the function will not have the effects you think you will. Every page that you want pagination added to, will also need code passed to the function.

If I remember correctly, there's a global function file? If so, it can be added to that.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...