Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Olavo Alexandrino  >  Generic Easy Pagination  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Generic Easy Pagination
Pagination of arbitrary listings
Author: By
Last change:
Date: 2004-01-11 15:25
Size: 1,753 bytes
 

Contents

Class file image Download
<?php require_once('YOU_PATH/adodb.inc.php'); ?>
<?php 
require_once('YOU_PATH/class.GenericEasyPagination.php'); ?>
<?
///////////////////////////////////////////////////////////////////
// Define Constants
if ($_GET["page"]!=""):        $page    $_GET["page"];    else:    $page    1;        endif;
define ('RECORDS_BY_PAGE',5);
define ('CURRENT_PAGE',$page);


///////////////////////////////////////////////////////////////////
// Connection Of DataBase
$objConnection = &ADONewConnection('mysql'); 
$objConnection->Connect('localhost','root','','test');


///////////////////////////////////////////////////////////////////
// Select Records By "PageExecute Method"
$strSQL " SELECT id_user,user_name FROM users ORDER BY user_name";
$objConnection->SetFetchMode(ADODB_FETCH_ASSOC);
$rs $objConnection->PageExecute($strSQL,RECORDS_BY_PAGE,CURRENT_PAGE);


///////////////////////////////////////////////////////////////////
// Display Records
if (!$rs->EOF)
{
    
$recordsFound $rs->_maxRecordCount;
    echo 
"RecordsLits:<br><br>";
    while(!
$rs->EOF)
    {
        echo 
"<strong>User Name:</strong> ".$rs->fields["user_name"]." (<strong>id</strong>: ".$rs->fields["id_user"].")<br>";
        
$rs->moveNext();
    }
    
    
///////////////////////////////////////////////////////////////////
    // Pagination
    
$GenericEasyPagination =& new GenericEasyPagination(CURRENT_PAGE,RECORDS_BY_PAGE,"eng");
    
$GenericEasyPagination->setTotalRecords($recordsFound);
    echo 
"<br>";
    echo 
"<strong>Records found: </strong>".$recordsFound;
    echo 
"<br>Records ";
    echo 
$GenericEasyPagination->getListCurrentRecords();
    echo 
"<br>";
    echo 
$GenericEasyPagination->getNavigation();
    echo 
"<br>";
    echo 
$GenericEasyPagination->getCurrentPages();
    echo 
"<br>";

}
?>