Login   Register  
PHP Classes
elePHPant
Icontem

File: example2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Lucas Tiago de Moraes  >  Data Page  >  example2.php  >  Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: Example 2
Class: Data Page
Calculate entries of listings with pagination
Author: By
Last change:
Date: 2013-06-25 06:58
Size: 680 bytes
 

Contents

Class file image Download
<?php
include_once 'DataPage.php';

$page = isset($_GET['page']) ? $_GET['page'] : 1;

$datapage = new DataPage;
$datapage->total_entries 200;
$datapage->entries_per_page 10;
$datapage->current_page $page;
$datapage->total_numbers 4;

if(
$datapage->previous_page()){
    echo 
"<a href='?page=".$datapage->previous_page()."'>Previous page</a> -";
}

foreach(
$datapage->array_numbers() as $row){
    if(
$row == $datapage->current_page){
        echo 
" <strong>$row</strong> ";
    }else{
        echo 
" <a href='?page=$row'>$row</a> ";
    }
}

if(
$datapage->next_page()){
    echo 
"- <a href='?page=".$datapage->next_page()."'>Next page</a>";
}
?>