<?php 
/* 
-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=- 
Name: 
        gnPaginate Class usage example 
 
Author: 
        Girish Nair <girishn2003_@_yahoo_._co_._in> 
 
Description: 
        This example shows how to use the gnPaginate class 
 
 
Terms: 
        Copyright (C) 2003  Girish Nair 
 
        This library is free software; you can redistribute it and/or 
        modify it under the terms of the GNU Lesser General Public 
        License as published by the Free Software Foundation; either 
        version 2.1 of the License, or (at your option) any later version. 
 
        This library is distributed in the hope that it will be useful, 
        but WITHOUT ANY WARRANTY; without even the implied warranty of 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
        Lesser General Public License for more details at: 
                http://www.gnu.org/copyleft/lesser.html 
 
        If you use this script in your application/website, please 
        send me an e-mail letting me know about it :) 
 
Bugs: 
        Please report any bugs you might find to my e-mail address 
        at (Girish Nair <girishn2003_@_yahoo_._co_._in>).  If you have already 
        created a fix/patch for the bug, please do send it to me so I can 
        incorporate it into my release. 
 
Suggestion: 
        I know there is a lot of scope for improvement! if you find any 
        suggestion useful for this program please send it to my e-mail address 
        at (Girish Nair <girishn2003_@_yahoo_._co_._in>). 
 
Donation: 
        If you found this class useful. and if you want to give something in 
        return then please donate Rs. 50/- (OR 1USD )to a charity organization 
        nearby. And let my name also be there along with yours :) 
 
Version History: 
        1.0        10 June, 2003        - InitialRelease 
-=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=--=-=- 
*/ 
 
require("gnPaginate.php"); 
if(!$pageNo) $pageNo=1; 
///initialise the gnPaginate class// 
//arguments (total number of items, no of items perpage) 
 
// this you get from any where  e.g. after an SQL statement 
// Or wherever you want, I use it directly :) 
$totalItems=11; 
$perPage=2; 
 
// print here your contents like this 
if($pageNo==1) { 
  $start=1; 
} else { 
  $start=($pageNo-1)*$perPage+1; 
} 
 
for ($i=$start;($i<($start+$perPage) && $i<=$totalItems);$i++ ) { 
 echo "<br>--$i--"; 
} 
 
// 
// An SQL statement will be like this 
// SELECT * FROM table_name LIMIT $start,$perPage 
// 
 
$gP=new gnPaginate($totalItems,$perPage); 
$gP->debug=1; /// set debug off/on depending on your requirement 
$extraQuery=$_GET; 
$extraQuery["newString"]="hello"; /// set a number of new arguments you want 
unset($extraQuery["pageNo"]); /// get the old page no out of next arguments 
 
 
/// e.g. show the page numbers from 1 to 4 (no need to show page numbers after 4) 
echo $gP->gnPShow($pageNo,$extraQuery,"    ",1,4); 
echo "<br>"; 
 
/// e.g. show all the page numbers 
echo $gP->gnPShowAll($pageNo,$extraQuery,"    "); 
echo "<br>"; 
 
/// e.g. show the floating page numbers with a NEXT & PREV link with only total 3 links on a page 
echo $gP->gnPShowNextPrev($pageNo,$extraQuery,"    ",3); 
echo "<br>"; 
 
/// e.g. show all the page numbers with a NEXT & PREV link 
echo $gP->gnPShowNextPrevAll($pageNo,$extraQuery,"    "); 
echo "<br>"; 
?> 
 
 |