PHP Classes

File: paging.php

Recommend this page to a friend!
  Packages of imran ahmed rahi   Paging Class   paging.php   Download  
File: paging.php
Role: Example script
Content type: text/plain
Description: The example script
Class: Paging Class
Display MySQL query results split in pages
Author: By
Last change:
Date: 21 years ago
Size: 803 bytes
 

 

Contents

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

$Dbcon = new DbConnection();
# number of records per page
$limit = 3;


$sql = "SELECT name FROM employee ";
$result = $Dbcon->ExecuteQuery($sql);
if($Dbcon->NumRows($result) > 0)
{
    $totrecords = $Dbcon->NumRows($result);
    $totpages = ceil($totrecords / $limit);
}

if(!isset($page))
{
    $page = 1;
    $offset = 0;
}
else
    $offset = ($page-1 ) * $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);
?>