PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Olavo Alexandrino   EasyPagination   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: EasyPagination
Pagination MySQL query records
Author: By
Last change:
Date: 20 years ago
Size: 2,313 bytes


Class file image Download
mysql_select_db("test") or die ("BD não existente");

if (
$_GET["page"]!=""): $page = $_GET["page"]; else: $page = 1; endif;

// Set current page
// Set the records listed in each page
// Set Language
// $pagination = new EasyPagination($page,2); => Portuguese Language
$pagination = new EasyPagination($page,2,"eng"); // English Language

// In case that it is necessary more values of variable, to use the method ' setGetVars ' to pass through links of navigation
// Example
vars: author, country and city

// Set the search for records
$sqlSearch = "SELECT id_user,user_name FROM users ORDER BY user_name";

// Same search thar gets the total number of records
$sqlNumRows = "SELECT COUNT(id_user) AS numTotal FROM users";

// Get Records
$SQLresult = $pagination->getResultData($page);
// Current Page
echo "Records of the page: <font color='#FF0000'><strong>$page</strong></font><br>";

// Gets the current records according to the current page
echo "Showing: <strong>".$pagination->getListCurrentRecords()."</strong><br>";

// Gets the total number of records
// Gets the total number of pages, according to the number of records in each page
echo "Result: <strong><font color='#FF0000'>".$pagination->getTotalRecords()."</font> occurrence(s) in <font color='#FF0000'>".$pagination->getPagesFound()."</font> page(s)</strong><br>";

// Gets the links for browsing
echo $pagination->getNavigation()."<br><br>";

// Gets the links of the current page, according to the current page
// Always from 1 to 10, 11 to 20, 21 to 30, and so forth
echo $pagination->getCurrentPages();

// Gets groups of links, from 10 to 10, oscillating as follows: (X)1,(X+1)1,(X+2)1
echo $pagination->getNavigationGroupLinks();

if (
"<br>Records: <br><br>";
    while (list(
$id_user,$user_name) = mysql_fetch_row($SQLresult)):?>
<strong>ID:</strong> <?echo $id_user;?> [<strong>Name</strong>: <?echo $user_name;?>]<br>