Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $userCount = countUsers(); // Count the amount of users
- $total_page = ceil($userCount / 25);
- $current_page = empty($_GET['page']) ? 1 : $_GET['page'];
- $previous_page = $current_page - 1;
- $next_page = $current_page + 1;
- $myPrev = "<div id='prevlink'><a href='".$_SERVER['PHP_SELF']."?page=$previous_page'>Previous</a></div>";
- $myNext = "<div id='nextlink'><a href='".$_SERVER['PHP_SELF']."?page=$next_page'>Next</a></div>";
- /* This creates your offset */
- if($current_page > 1){
- $myOffset = ($current_page - 1) * 25;
- }else{
- $myOffset = 0;
- }
- /* I created a function that fetches all my user data, and add it to an array ($userData),
- with $myOffset as an argument to add to my mySQL query */
- $userData = fetchAllUsers(25, $myOffset); //Fetch information for all users
- /* Checking to make sure that the links are needed; last page no next link, first page
- no previous link */
- if($next_page > $total_page) {
- $myNext = "";
- }
- if($previous_page < 1) {
- $myPrev = "";
- }
- echo $myPrev . $myNext;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement