pagination

Run Settings
LanguagePHP
Language Version
Run Command
<?php $limit = 5; $totalBooks = count($books); $totalPages = ceil($totalBooks / $limit); $currentPage = isset($_GET['page']) ? $_GET['page'] : 1; $offset = ($currentPage - 1) * $limit; // Modified query with pagination $queryBook = mysqli_query($conn, "SELECT * FROM books LIMIT $limit OFFSET $offset"); // Reset $books array before fetching paginated data $books = []; while ($book = mysqli_fetch_assoc($queryBook)) { $books[] = $book; } ?> <!-- Pagination Controls --> <nav aria-label="Page navigation"> <ul class="pagination"> <?php for ($page = 1; $page <= $totalPages; $page++) : ?> <li class="page-item <?php if ($page == $currentPage) echo 'active'; ?>"> <a class="page-link" href="?page=<?= $page; ?>"><?= $page; ?></a> </li> <?php endfor; ?> </ul> </nav>
Editor Settings
Theme
Key bindings
Full width
Lines