PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Lucas Tiago de Moraes   Data Page   example1.php   Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example 1
Class: Data Page
Calculate entries of listings with pagination
Author: By
Last change:
Date: 9 years ago
Size: 501 bytes
 

Contents

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

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

$datapage = new DataPage(200, 10, $page, 8);

echo
"<a href='?page=".$datapage->first_page()."'>First page</a> -";

for(
$i=$datapage->start_number(); $i<=$datapage->end_number(); $i++){
    if(
$i == $datapage->current_page){
        echo
" <strong>$i</strong> ";
    }else{
        echo
" <a href='?page=$i'>$i</a> ";
    }
}

echo
"- <a href='?page=".$datapage->last_page()."'>Last page</a>";
?>