<?php

/*
* Paging class by Thomas Smit 21/07/06 - 22/07/06
*/

class paging
{

    public 
$perpage;          // Entries shown per page
    
public $records;          // Total records returned
    
public $pages;            // Number of pages
    
public $start;            // Record to start from
    
public $current;          // The current page

    /*
    * __construct() - class constructor
    * @param records - total records
    * @param perpage - records per page
    * @param start - which record to start from
    * @return void
    */

    
public function __construct($records$perpage$start)
    {
        
$this->perpage $perpage;
        
$this->records $records;
        
$this->pages = ($records $perpage) ? ceil($records $perpage) : 1;
        
$this->start $start;
        
$this->current = ($start $perpage) + 1;
    }

    
/*
    * first() - generate "first" link
    * @return int
    */

    
public function first()
    {
        if(
$this->pages 1)
            return 
0;
    }

    
/*
    * previous() - generate "previous" link
    * @return int
    */

    
public function previous()
    {
        if(
$this->pages 1)
            return (
$this->start $this->perpage);
    }

    
/*
    * next() - generate "next" link
    * @return int
    */

    
public function next()
    {
        if(
$this->pages 1)
            return (
$this->start $this->perpage);
    }

    
/*
    * last() - generate "last" link
    * @return int
    */

    
public function last()
    {
        if(
$this->pages 1)
            return (
$this->pages $this->perpage) - $this->perpage;
    }

}

?>