Login   Register  
PHP Classes
elePHPant
Icontem

File: usage

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nikolai Zujev  >  OutputNavigator  >  usage  >  Download  
File: usage
Role: Documentation
Content type: text/plain
Description: how to use
Class: OutputNavigator
Class to make per page output with 1 2 3 4 5>> >>>
Author: By
Last change:
Date: 2003-02-14 00:55
Size: 1,589 bytes
 

Contents

Class file image Download
<?
/*
demo - http://80.235.107.98:89/Complete_Scripts/PHP/output_navigator/

    HOW TO USE:

1) Init all open vars:

	$iRowLimit = 10;
	$iPageLimit = 10;
	$sKey = 'page';
	$sNoRes = 'sorry, no records to display';
	$sCss = 'navi';
	$sShowReS = 'display from %d to %d of %d records - %d pages';

2) Make SQL query to count total records

$res = mysql_query("SELECT * FROM table");
$iRecTotal = mysql_num_rows( $res );      

3) Prepare Data for Class

	$navigation = array(
	    'sKey' => $sKey, // page handler
	    'iRowT' => $iRecTotal,
	    'iRowL' => $iRowLimit,
	    'iPageL' => $iPageLimit,
	    'iPageC' => $HTTP_GET_VARS[$sKey],
	    'sQuery' => basename($PHP_SELF)."?var=2",  // without page handler
	    'sNoRes' => $sNoRes,
	    'sCss' => $sCss);

4) Create Class Obj

	$nBar = new OutputNavigator( $navigation );

5) Get useful vars

    list($iRowTotal, $iRowOffset, $iRowBegin, $iRowEnd, $iPageTotal) = $nBar->getCountData();
    $sShowReS = sprintf($sShowReS, $iRowBegin, $iRowEnd, $iRowTotal, $iPageTotal);

7) Make SQL query to count by  LIMIT $iRowOffset, $iRowLimit

$res = mysql_query("SELECT * FROM table LIMIT $iRowOffset, $iRowLimit");

8) Output alldata from DB

    if($iRowTotal)
    {
	    print $sShowReS."<br>";

	    for($i = $iRowBegin; $i <= $iRowEnd; $i++)
	    {
                list($val1, $var2, ..) = mysql_fetch_array( $res );
	        print "record nr:".$i." $var1 - $var2 ... <br>";
	    }

	    print $sShowReS."<br>";
    }

9) Print Navigation Bar

	print $nBar->getNavBar();
*/
?>