<?
/*
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();
*/
?>
|