diff --git a/bans.php b/bans.php index 21b3c0f..807c6c8 100644 --- a/bans.php +++ b/bans.php @@ -37,7 +37,7 @@ $page = new Page(); - print_pager("bans.php"); ?> + print_pager("bans.php", $page->settings->table_bans); ?> print_footer(); ?> diff --git a/includes/page.php b/includes/page.php index fe40c15..eb0e8cd 100644 --- a/includes/page.php +++ b/includes/page.php @@ -10,7 +10,7 @@ class Page { $this->settings = $settings; $this->uuid_name_cache = array(); $this->time = microtime(true); - $this->page = 0; + $this->page = 1; if (isset($_GET['page'])) { $page = $_GET['page']; // user input @@ -27,7 +27,8 @@ class Page { $offset = 0; if ($this->settings->show_pager) { - $offset = ($limit * $this->page); + $page = $this->page - 1; + $offset = ($limit * $page); } $query = "SELECT * FROM $table $active_query GROUP BY $table.id ORDER BY time DESC LIMIT :limit OFFSET :offset"; $st = $this->conn->prepare($query); @@ -123,17 +124,28 @@ class Page { '); } - function print_pager($page) { + function print_pager($page, $table) { if (!$this->settings->show_pager) return; - $prev = $this->page - 1; + $result = $this->conn->query("SELECT COUNT(*) AS count FROM $table")->fetch(PDO::FETCH_ASSOC); + $total = $result['count']; + + $pages = (int)($total / $this->settings->limit_per_page) + 1; + + $cur = $this->page; + $prev = $cur - 1; $next = $this->page + 1; $pager_prev = "