From 177c6bd1e8e7285b449e0a2002a6df4f827c12ed Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 11 Mar 2015 10:42:34 +0000 Subject: [PATCH] routeSQL : push on the last page if the values are too high git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2001 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- routeSQL.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routeSQL.php b/routeSQL.php index 663d9a6..248c0f1 100644 --- a/routeSQL.php +++ b/routeSQL.php @@ -157,14 +157,17 @@ class routeSQL $titles = $this->objectDB->titles (); if ($page === null || $page === "") $page = 1; if ($num === null || $num === "") $num = 10; + $page = intval ($page); + $num = intval ($num); if ($num > 1000) $route->redirect ("/".$this->url_prefix."?page=$page&num=1000", ""); if ($page < 1) $route->redirect ("/".$this->url_prefix."?page=1&num=$num", ""); - // TODO : Push on the last page + // Push on the last page if the values are too high if ($page*$num > count ($datas)) { - $route->redirect ("/".$this->url_prefix, ""); + $maxPage = intval(count ($datas)/$num); + $route->redirect ("/".$this->url_prefix."?page=$maxPage&num=$num", ""); } $content = $this->showflash ();