pdo; if (isset($_GET["all"])) $all = true; /* Get records amount */ $STH = $pdo->query ("SELECT COUNT(*) FROM `hosts`" . ($all ? "" : " WHERE `blacklisted` = 0")); $records = $STH->fetchColumn(); $pages = intdiv($records, $options["tableitems"]) + 1; /* Get records with limit */ $STH = $pdo->query ("SELECT `host`, `base64`, `base32`, `last_seen` FROM `hosts`" . ($all ? "" : " WHERE `blacklisted` = 0") . " LIMIT " . $offset . ", " . $options["tableitems"]); $rows = $STH->fetchAll(PDO::FETCH_ASSOC); $template = $twig->load('all.twig'); echo $template->render(['current' => $page, 'total' => $pages, 'hosts' => $rows, 'records' => $records, 'all' => $all]);