PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Pankaj Kumar Jha  >  Pagination Class for paging  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: example page of pagination
Class: Pagination Class for paging
Generate links to browse listings split in pages
Author: By
Last change: changing in page
Date: 11 years ago
Size: 3,104 bytes
 

Contents

Class file image Download
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<?php
     
      
include("pagination.php")
           

           
           
$p = $_GET['page'];
           
$p=(isset($p)) ? $p : 1;
           
$preScreen=$_GET['startpage'];
           
$preScreen=(isset($preScreen)) ? $preScreen : 1;
           
           
$pagination = new Pagination();
           
$pagination->setCurrentPage($p);
           
$pagination->setStartPage ($preScreen);
           
$pagination->setTotalPerPage(15);
           
$pagination->setTotalPagePerScreen(15);
   


              
$totSql = "select count(*) from ".REGISTER_USERS." WHERE dealer_user_id =0";
            
           
$totQuery = mysql_query($totSql) or die(mysql_error());
           
$totResults = mysql_num_rows($totQuery);
           
$totPages = $pagination->getPaginationResult($totResults);
 
           
$totSql .= " LIMIT " . $pagination->getFirstResult(). " , " . $pagination->getTotalPerPage() ;
           
$exe = @mysql_query($query);
           
           
// inset your code t display records
           
           
       
             //return pagination text
            
echo $pagination->getPaginationLink("userlist.php?" ,"cate_name_blue");
           
           
           
           
           
/********************************************************************************************************/
            /**
            /** or use this code to custom pagination
            /**
            /********************************************************************************************************/
           

           
$p = $pagination->getCurrentPage();
           
$preScreen=$pagination->getStartPage();
           
$paginationLink="";
           
$firstPage="1";
       
            foreach(
$totPages as $pageNumber)
            {

               
$firstPage=$pageNumber;
                if(
$pageNumber == $p)
                {
                   
                       
$paginationLink .= '<a href="'. $link . 'page='. $pageNumber . '&startpage=' . $preScreen . '"><strong>&nbsp;&nbsp;'.$pageNumber .'</strong></a>';
                }else if(
$pageNumber == ">>"){
               
                       
$paginationLink .= '<a href="' . $link . 'page='. $pagination->getNextPage() .'&startpage=' . $pagination->getNextPage() . '" class="' . $style . '" >&nbsp;&nbsp;Next >> </a>';
               
                
                }else if(
$pageNumber == "<<"){
               
                       
$paginationLink .= '<a href="' . $link . 'page='. $pagination->getPreviousPage() . '&startpage=' . $pagination->getPreviousPage() . '" class="' . $style . '" >&nbsp;&nbsp;<< Previous</a>';
               
                            
                }
                else
                {
                       
$paginationLink .= '<a href="' . $link . 'page='. $pageNumber . '&startpage=' . $preScreen . '" class="' . $style . '" >&nbsp;&nbsp;'.$pageNumber.'</a>';
                }

            }
          
           echo
$firstPage==1)? "": $paginationLink ;
           
            
/********************************************************************************************************/
            /**
            /** end of pagination
            /**
            /********************************************************************************************************/


</body>
</
html>

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