Login   Register  
PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Radovan Janjic  >  PHP Pagination  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: PHP Pagination
Generate links to browse MySQL query result pages
Author: By
Last change: - Added first and last page identification
- Small fixes
- Improved description
Date: 1 year ago
Size: 1,747 bytes


Class file image Download

include "pagination.class.php";

$p = new pagination;

// Items per page
$p->perPage 10;

// Pagination left from current
$p->paginationLeft 3

// Pagination right from current
$p->paginationRight 3

// Link href
$p->path '?example=%d'// or $p->path = 'example/%d/';

// Paginaion appearance
'nav_prev'             => '<a href="%s" class="prev"><span>prev</span></a>',
'nav_number_link'     => '<a href="%s"><span>%d</span></a>',
'nav_number'         => '<a href="javascript:;" class="active"><span>%d</span></a>',
'nav_more'             => '<a href="javascript:;" class="more"><span>...</span></a>',
'nav_next'             => '<a href="%s" class="next"><span>next</span></a>'

// Items count        

// Current page

// Echo pagination
echo $p->paginate();

<p>SELECT * FROM some_table LIMIT <?php echo $p->getLimit(); ?><?php echo $p->getLimitOffset(); ?><br />

if ($p->first
"You are on first page.";
    if (
"You are on last page.";

    a { 
        border:solid 1px #666666;
    a:hover {
    a.active {
    a.prev, a.next {
    a.active, a.more {
    p {
    div {
        margin:0 auto;