Простенький класс навигации by CMEX обычно не использую настройки к-ва постов на страницу, все по стандарту по 10 пунктов)

$k_post = 'общее количество';

$n = new Navigator($k_post, 10);

потом чекаем типо $blabla = query("SELECT `id` FROM `blabla` ORDER BY `id` ASC LIMIT {$n->start()}, 10" );

ну сам вывод echo $n->navi() ;

может кому пригодится

                        
<?php
class Navigator {
private $k_page;
private $page;
private $start;

public function __construct($k_post, $k_p_str = 10) {
$this->k_page = $this->totalPages($k_post, $k_p_str);
}

private function currentPage() {
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? intval($_GET['page']) : 1;

if ($page !== 'end') {
if ($page < 1) {
$page = 1;
} else if ($page > $this->k_page) {
$page = $this->k_page;
}
} else {
$page = $this->k_page;
}

return $page;
}

private function totalPages($k_post, $k_p_str = 10) {
if ($k_post != 0) {
return ceil($k_post / $k_p_str);
} else {
return 1;
}
}

public function start() {
$this->page = $this->currentPage();
$this->start = ($this->page - 1) * 10;
return $this->start;
}

public function navi($link = '?') {
$this->page = $this->currentPage();
$output = '';

if ($this->k_page > 1) {
$output = '<div class="navigation">';

if ($this->page > 1) {
$output .= '<a class="pag" href="' . $link . 'page=1">&lt;&lt;</a> ';
}

for ($i = max(1, $this->page - 2); $i <= min($this->k_page, $this->page + 2); $i++) {
if ($i == $this->page) {
$output .= '<span class="pag">' . $i . '</span> ';
} else {
$output .= '<a class="pag" href="' . $link . 'page=' . $i . '">' . $i . '</a> ';
}
}

if ($this->page < $this->k_page) {
$output .= '<a class="pag" href="' . $link . 'page=' . $this->k_page .'">&gt;&gt;</a>';
}

$output .= '</div>';
}

return $output;
}

}
?>
1 101 0
Без комментариев...