PHP Classes

File: fbird_paging.php

Recommend this page to a friend!
  Packages of meta   metafire   fbird_paging.php   Download  
File: fbird_paging.php
Role: Example script
Content type: text/plain
Description: paging test
Class: metafire
database abstraction layer for firebird/interbase
Author: By
Last change: remove intPaging
Date: 24 years ago
Size: 1,386 bytes
 

Contents

Class file image Download
<?
    require("metafire.lib.php");
    
    $fbird = new metafire;
    
    //test Query paging
    $strTable="employee";
    $aryField="first_name,last_name";
    $intMax=10;
    $intPaging=10;
    if (!isset($page) || $page==1) {
        $page=1;
        $intOffset=$page-1;

    } else {
        $intOffset=$intPaging*($page-1);
    }
    $intQuery=$fbird->PagingSelect($strTable,$aryField,' ',$intMax,$intOffset);
    $rows=$intOffset;
    while ($fbird->fetchObject($intQuery)) {
        $rows++;
        echo $rows.". ".$fbird->fetchRow("first_name")." ".$fbird->fetchRow("last_name")."<br>";
    }
    echo "Query script: ".$fbird->strSQL."<br>";
    $freeResult=$fbird->FreeQueryResult($intQuery);
    echo "Page: ";
    $sql="select count(*) as total_rows from $strTable";
    $intQuery=$fbird->Query($sql);
    if ($fbird->fetchObject($intQuery)) { $rows=$fbird->fetchRow("total_rows"); }
    $ceil=ceil($rows/$intPaging);
    
    if ($page==0 || $page==1) {
        echo "<< ";
        $page=1;
    } else {
        $prev=$page-1;
        echo "<a href=$PHP_SELF?page=$prev>";
        echo "<<";
        echo "</a>  ";
    }
    
    echo "</a> ";
    
    for ($i=1;$i<=$ceil;$i++) {
        if ($i==$page) {
            echo "<b>$i</b> ";
        } else {
            echo "<a href=$PHP_SELF?page=$i>".$i."</a> ";
        }
    }
    if ($page==$ceil) {
        echo " >>";
    } else {
        $next=$page+1;
        echo "  <a href=$PHP_SELF?page=$next>";
        echo ">><br> ";
        echo "</a>";
    }

    echo "<br>";    
    echo "Done!";

?>