PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Zafer Karaca   Cre pager   example1.php   Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: example1.php
Class: Cre pager
Generate links to browse MySQL query results
Author: By
Last change:
Date: 12 years ago
Size: 1,333 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];
   
// 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>";
    }
 
 
?>