PHP Classes

File: example

Recommend this page to a friend!
  Classes of mano kalousdian   Flexible pagination class   example   Download  
File: example
Role: Example script
Content type: text/plain
Description: an example
Class: Flexible pagination class
Split MySQL query results in multiple pages
Author: By
Last change: better example
Date: 14 years ago
Size: 1,801 bytes
 

Contents

Class file image Download
<?php
 
include "paginationclass.php";

 
$query="select * from table order by tablename asc";
 
$passingparams="variable1=1&variable=2"; //extra parameters you would want to send
  //initializing the class
 
$thispage=isset($_REQUEST['thispage'])?$_REQUEST['thispage']:1; //this is required
           
$pager=new pagination($connection_link,$query,$thispage,100,$passingparams); //100 is the number of records per page
             
$pager->type="normal"; //dropdown,normal
             
$pager->pagingdistance="2"; //it is the distance of upper and lower part of the page number,can be 0 to show all the records
             
$pager->prev="<"; //you can also put html tags or images instead of a character
             
$pager->next=">";
             
$pager->first="<<";
             
$pager->last=">>";
             
$pager->showifonepage=false; //if the records dont need pagination and they can be displayed in one page, by 'false' means the paging next and previous links would not be visible
             
//example usage in a loop
?>
<?php $res
=$pager->paginate(); //you can treat the result coming from pagination as a query link
    
if(mysql_num_rows($res)==0){
        
//some code here
    
}
//values you can get from the pagination
$pager->first(); //will show a link that takes you to the first page, the link will be '<<' as supplied above
$pager->previous(); //will show a link that takes you to the previous page, the link will be '<' as supplied above
$pager->next(); //will show a link that takes you to the next page, the link will be '>' as supplied above
$pager->last(); //will show a link that takes you to the last page, the link will be '>>' as supplied above

$pager->numrecords; //will show you the total records found
$pager->thispage; //will show you what page are you on
$pager->numpages; //will show you the total number of pages?>