майа пагинация... для знаюсчего
<?php
class pagination extends Ci_model
{
public $num, $page, $result, $posts, $total, $start;
public function init ($opt=array())
{
foreach ($opt as $key => $value)
{
$this->$key=$value;
}
$this->total = intval(($this->posts - 1) / $this->num) + 1;
if(empty($this->page) or $this->page < 0) $this->page = 1;
if($this->page > $this->total) $this->page = $this->total;
$this->start = $this->page * $this->num - $this->num;
}
public function display ($url)
{
if ($this->page != 1 )
$pervpage = '<a class="normal" href="'.$url.'1">Начало</a><a class="normal" href="'.$url.($this->page - 1).'">'.($this->page - 1).'</a> ';
else $pervpage='';
if ($this->page != $this->total)
$nextpage = '<a class="normal" href="'.$url.($this->page+1).'">'.($this->page+1).'</a><a class="normal" href="'.$url.$this->total.'">Конец</a>';
else $nextpage='';
if($this->page - 2 > 0 )
$page2left = '<a class="normal" href="'.$url.($this->page - 2).'">'.($this->page-2).'</a>';
else $page2left='';
if($this->page - 1 > 0 )
$page1left = '<a class="normal" href="'.$url.($this->page - 1).'">'.($this->page - 1).'</a>';
else $page1left='';
if($this->page + 2 <= $this->total)
$page2right = '<a class="normal" href="'.$url.($this->page + 2).'">'.($this->page + 2).'</a>';
else $page2right='';
if($this->page + 1 <= $this->total)
$page1right = '<a class="normal" href="'.$url.($this->page + 1 ).'">'. ($this->page + 1).'</a>';
else $page1right='';
$this->page='<a href="'.$url.$this->page.'" class="active">'.$this->page.'</a>';
if ($this->total <= $this->num)
return '<div class="page">'.$pervpage.$page2left.$page1left.$this->page.$page1right.$page2right.$nextpage.'</div>';
}
}