<?php require_once "../../includes/initialize.php"; if (!$session->is_logged_in()) { redirect_to("login.php"); } ?> <?php // 1. the current page number ($current_page) $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1; // 2. records per page ($per_page) $per_page = 10; // 3. total record count ($total_count) $total_count = Request::count_all(); //4. to limit pagination number // 3 means abc[page]efg -> 3 right, 3 left $stages = 2; $pagination = new Pagination($page, $per_page, $total_count); // Instead of finding all records, just find the records // for this page $sql = "SELECT * FROM requests "; if (isset($_POST['submit'])) { $department = strtolower($_POST['department']); } else { $department = "library"; } $sql .= "WHERE department='{$department}' ORDER BY created DESC "; $sql .= " LIMIT {$per_page} "; $sql .= "OFFSET {$pagination->offset()} "; $requests = Request::find_by_sql($sql); if (empty($requests)) {