File: example2.php

Recommend this page to a friend!
  Classes of Zafer Karaca  >  Cre pager  >  example2.php  >  Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: example2.php
Class: Cre pager
Generate links to browse MySQL query results
Author: By
Last change:
Date: 9 years ago
Size: 1,472 bytes
 

Contents

Class file image Download
<?php
   
include("page.class.php");
   
   
// connection to the database
   
mysql_connect('localhost', 'root', '');
   
// select database
   
mysql_select_db('pager');
   
   
   
   
   
   
// start pager class
   
$pager = new Pager();
   
// page number
   
$pager->PageNumber=$_GET[PageNumber];
   
// you can change perpage record
   
$pager->PerPages = 5;
   
// you can change link page number limit
   
$pager->PageNumberLimit = 5;
   
// sql query
   
$pager->sql_query('SELECT * FROM books');
   
   
   

   
   
    echo
"<br>Total Pages: ".$pager->TotalPage();
    echo
"<br>Total Records: ".$pager->TotalRecord();
    echo
"<br>Current Page : ".$pager->PageNumber();
    echo
"<br>Next Page : ".$pager->NextPage();
    echo
"<br>Previous Page : ".$pager->PreviousPage();
    echo
"<br>Remaining Page : ".$pager->RemainingPage();
   
   
        echo
"<hr>";
   
// print records
   
foreach($pager->mysql_fetch() as $row){
        echo
"<br>".$row['ID']."-".$row['BookName'];
    }
   
   

     echo
"<hr>";
   

   
// Previous Page Link
   
if($pager->PreviousPage())
    {
    echo
" <a href='?PageNumber=".$pager->PreviousPage()."'>Previous</a>";
    }
   
   
   
   
// print page link number
   
foreach($pager->PageLink() as $key=>$value){
       
    if(
$pager->PageNumber()==$key)
    {
    echo
"<b>".$key."</b>";
    }
    else
    {
    echo
" <a href='?PageNumber=".$key."'>".$key."</a>";
    }
   
    }
   
   
   
// Next Page Link
   
if($pager->NextPage())
    {
    echo
" <a href='?PageNumber=".$pager->NextPage()."'>Next</a>";
    }
 
?>


For more information send a message to info at phpclasses dot org.