Login   Register  
PHP Classes
elePHPant
Icontem

File: paging.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of imran ahmed rahi  >  Result set paging  >  paging.php  >  Download  
File: paging.php
Role: Example script
Content type: text/plain
Description: Example file for working with the class file
Class: Result set paging
Generate links to browse listings split in pages
Author: By
Last change:
Date: 9 years ago
Size: 905 bytes
 

Contents

Class file image Download
<?php
#include "DbConnection.php";
include "pagingClass2.php";

# Your database connection object
$Dbcon = new DbConnection();

# number of records per page
$limit 3;

$sql "SELECT name FROM employee ";
$result $Dbcon->ExecuteQuery($sql);
if(
$Dbcon->NumRows($result) > 0)
{
    
# Total records in DB for the query
    
$totrecords $Dbcon->NumRows($result);

    
# Possible total pages
    
$totpages ceil($totrecords $limit);
}

if(!isset(
$page))
{
    
$page 1;
    
$offset 0;
}
else
    
$offset = ($page-) * $limit;

$sql "SELECT name FROM employee LIMIT $offset,$limit";
$result $Dbcon->ExecuteQuery($sql);
if(
$Dbcon->NumRows($result) > 0)
{
    
$paging = new PagingClass2($totrecords$limit);
    
$data $paging->DisplayPaging($page);
}
print 
$data."<br>";
while(
$rows $Dbcon->FetchArray($result))
{
        print 
$rows[0]."<br>";
}
$Dbcon->FreeResult($result);
?>