<?
class Page {
public function __construct($count,$limit=15){
$this->count=$count;
$this->limit=(int)$limit;
$this->page=$this->page();
$this->start=$this->start();
$this->k_page=$this->k_page();
}
public function page(){
if (isset($_GET['page'])){
if ($_GET['page'] == 'last'){
$page=$this->k_page;
}
else{
$page=(int)$_GET['page'];
}
}else
$page=1;
return $page;
}
public function start(){
$start=$this->limit*$this->page;
$start=$start-$this->limit;
return $start;
}
public function k_page(){
$pages=ceil($this->count/$this->limit);
return $pages;
}
public function out($link){
$url=null;
if ($this->k_page > 1){
$url='<table cellpadding="0" cellspacing="0" style="width: 100%"><tr><td class="pages" style="width: 35%; border-radius: 6px 0px 0px 6px">';
if ($this->page > 1)$url=$url.'<a style="border: 0px; border-radius: 6px 0px 0px 6px" href="'.htm($link).($this->page-1).'" class="page">«Назад</a>';
else $url=$url.'«Назад';
$url=$url.'</td><td class="pages" style="width: 30%">';
$url=$url.$this->page.'/'.$this->k_page;
$url=$url.'</td><td class="pages" style="width: 35%; border-radius: 0px 6px 6px 0px">';
if ($this->page != $this->k_page)
$url=$url.'<a style="border: 0px; border-radius: 0px 6px 6px 0px" href="'.htm($link).($this->page+1).'">Вперед»</a>';
else $url=$url.'Вперед»';
$url=$url.'</td></tr></table>';
}
return $url;
}
}
На, вырвал из anicms