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: 21 years ago
Size: 2,313 bytes
 

Contents

Class file image Download
<?
mysql_connect
("localhost","root","");
mysql_select_db("test") or die ("BD não existente");
include
"class.EasyPagination.php";

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
*/
//$pagination->setGetVars("author=olavo&country=brazil&city=recife");

// Set the search for records
$sqlSearch = "SELECT id_user,user_name FROM users ORDER BY user_name";
$pagination->setSQLSearch($sqlSearch);

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

// Get Records
$SQLresult = $pagination->getResultData($page);
?>
<center>
<?
// 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>";

echo
"<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();
echo
"<br>";

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

if (
mysql_num_rows($SQLresult)>=1):
    echo
"<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>
    <?endWhile;?>
<?
endIf;?>
</center>