Здравейте имам следният проблем.При търсене на ключова дума от ДБ всичко е на ред, но когато се опитам да страницирам дадните резултати не се получава. Идвам на page=2 и все едно не съм пускал заявка пробвах да присвоя полето от което търся към сесиия обаче пак не стана. Моля помогнете ето го и класа за страницирането
[/quote]
Код:
<?php
define('FIRST_PAGING', 'Първа');
define('LAST_PAGING', 'Последна');
define('PREVIOUS_PAGING', 'Предишна');
define('NEXT_PAGING', 'Следваща');
define("DEFAULT_PAGING", 1);
define("MARGIN_PAGING", 2);
class paging
{
private $_total;
private $_perPage;
private $_maxPages;
private $_currentPage;
private $_typePaging;
private $_margin;
private $_start;
private $_end;
private $_links;
public $_offset;
public function __construct($total, $perpage, $current, $type = 1, $margin = 5)
{
$this->_currentPage = (int)$current;
$this->_total = (int)$total;
$this->_perPage = (int)$perpage;
$this->_typePaging = (int)$type;
$this->_margin = (int)$margin;
$this->createPaging();
$this->createStartEnd();
}
private function createPaging()
{
$this->_currentPage = max($this->_currentPage, 1);
$this->_maxPages = ceil($this->_total / $this->_perPage);
$this->_offset = ($this->_currentPage - 1) * $this->_perPage;
$this->_currentPage = $this->_currentPage > $this->_maxPages ? $this->_maxPages : $this->_currentPage;
}
private function createStartEnd()
{
switch ($this->_typePaging)
{
case MARGIN_PAGING:
$this->_start = $this->_currentPage - $this->_margin;
$this->_start = $this->_start < 1 ? 1 : $this->_start;
$this->_end = $this->_currentPage + $this->_margin;
$this->_end = $this->_end > $this->_maxPages ? $this->_maxPages : $this->_end;
break;
default:
$this->_start = 1;
$this->_end = $this->_maxPages;
break;
}
}
public function createLinks($url = '?')
{
$this->_links = '';
if($this->_currentPage <= 1) {
$this->_links .= '<< ';
} else {
$this->_links .= '<a href="'.$url.'page=1"> << </a> ';
}
for ($i = $this->_start; $i <= $this->_end; ++$i)
{
$this->_links .= $this->_currentPage == $i ? ' <span class="active">' . $i . '</span> ' : ' <a href="'.$url.'page='.$i.'">'.$i.'</a> ';
}
if($this->_currentPage >= $this->_maxPages)
{
$this->_links .= '>> ';
}
else
{
$this->_links .= ' <a href="'.$url.'page='.$this->_maxPages.'">>></a>';
}
}
public function printLinks()
{
return $this->_links;
}
}
?>