From d8d419317da4beed141b9c1d381be4b8da6a80bb Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 18 Oct 2010 22:17:43 +0200 Subject: [PATCH] Last page with empty result (thanks to Frantisek Svoboda) --- adminer/select.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 21e8ef48..73c0bc77 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -209,7 +209,7 @@ if (!$columns) { $page = $_GET["page"]; if ($page == "last") { $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")); - $page = floor(($found_rows - 1) / $limit); + $page = floor(max(0, ($found_rows - 1) / $limit); } $query = "SELECT" . limit((intval($limit) && $group && count($group) < count($select) && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from, ($where ? "\nWHERE " . implode(" AND ", $where) : "") . $group_by, ($limit != "" ? intval($limit) : null), ($page ? $limit * $page : 0), "\n");