{% else-1 %}
MeXaHuK * 2.65
(14 ноя 2015, 18:27) (0/0) [0]
Mobiaaa, results_on_page 25
MeXaHuK * 2.65
(14 ноя 2015, 18:25) (0/0) [0]
Урмэлис, менял та же ошибка
MeXaHuK * 2.65
(14 ноя 2015, 17:35) (0/0) [0]
вывод навигации

$cr = $db -> res("SELECT COUNT(*) FROM `chatik_comms`"*;
$navi = new navi($cr, '?');
journal::update('chatik', 0, "/chatik/?page=".$navi -> page);
$posts = array();
$q = $db -> q("SELECT * FROM `chatik_comms` ORDER BY `time` DESC LIMIT ".$navi -> start.", ".$set -> results_on_page);
MeXaHuK * 2.65
(14 ноя 2015, 15:37) (0/0) [0]
Выдает ошибку Warning: Division by zero in /папка/файл.php on line 13

13 строка $this -> count_pages = ceil($count_results / $this -> rop);


<?
class navi {
public $count_pages = 0;
public $page = 1;
public $start = 0;
public $show = null;
public $rop = 10; // к-тво результатов на странице
public function __construct($count_results, $page_link) {
global $set;
$this -> rop = $set -> results_on_page;
# считаем к-тво страниц
if ($count_results <> 0) {
$this -> count_pages = ceil($count_results / $this -> rop);
} else $this -> count_pages = 1;
# узнаем текущую страницу
if (isset($_GET['page'])) {
if (is_numeric($_GET['page']))$this -> page = intval($_GET['page']);
}
if ($this -> page < 1)$this -> page = 1;
if ($this -> page > $this -> count_pages)$this -> page = $this -> count_pages;
# узнаем начальный результат
$this -> start = $this -> rop * $this -> page - $this -> rop;
# выводим навигацию
if ($this -> count_pages > 1) {
$this -> show .= "<hr>\n";
$this -> show .= "<ul class='navigation'>\n";
if ($this -> page != 1)$this -> show .= "<li><a href='".$page_link."page=1' title='Страница №1'>1</a></li>";
else $this -> show .= "<li><span>1</span></li>";
for ($ot=-3; $ot<=3; $ot++) {
if ($this -> page + $ot > 1 && $this -> page + $ot < $this -> count_pages) {
if ($ot == -3 && $this -> page + $ot > 2)$this -> show .= "..";
if ($ot != 0)$this -> show .= "<li><a href='".$page_link."page=".($this -> page + $ot)."' title='Страница №".($this -> page + $ot)."'>".($this -> page + $ot)."</a></li>";
else $this -> show .= "<li><span>".($this -> page + $ot)."</span></li>";
if ($ot == 3 && $this -> page + $ot < $this -> count_pages - 1)$this -> show .= "..";
}
}
if ($this -> page != $this -> count_pages)$this -> show .= "<li><a href='".$page_link."page=".$this -> count_pages."' title='Страница №".$this -> count_pages."'>".$this -> count_pages."</a></li>";
elseif ($this -> count_pages > 1)$this -> show .= "<li><span>".$this -> count_pages."</span></li>";
$this -> show .= "</ul>\n";
}
}
public function __call ($fnc_name, $args) {
switch ($fnc_name):
case 'count_pages':
return Удалён -> count_pages;
case 'page':
return Удалён -> page;
case 'start':
return Удалён -> start;
case 'show':
return Удалён -> show;
case 'rop':
return Удалён -> rop;
endswitch;
}
}
?>
  • 1 из 1