├── .DS_Store ├── README.md ├── config └── db.php └── index.php /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SinghDigamber/php-pagination/8e21c7bba5247525ea497ca04100d200b4e94ee7/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # php-pagination 2 | This tutorial explains how to create pagination in PHP 7 and MySQL using the Bootstrap 4 Pagination UI component. Also, learn how to set the dynamic limit in pagination with the session, create prev, next feature, active class in pagination to display results fetched from MySQL database. 3 | 4 | [Create Pagination in PHP 7 with MySQL and Bootstrap](https://www.positronx.io/create-pagination-in-php-with-mysql-and-bootstrap/) -------------------------------------------------------------------------------- /config/db.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 11 | } catch(PDOException $e) { 12 | echo "Database connection failed: " . $e->getMessage(); 13 | } 14 | 15 | ?> 16 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM authors LIMIT $paginationStart, $limit")->fetchAll(); 15 | 16 | // Get total records 17 | $sql = $connection->query("SELECT count(id) AS id FROM authors")->fetchAll(); 18 | $allRecrods = $sql[0]['id']; 19 | 20 | // Calculate total pages 21 | $totoalPages = ceil($allRecrods / $limit); 22 | 23 | // Prev + Next 24 | $prev = $page - 1; 25 | $next = $page + 1; 26 | ?> 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | PHP Pagination Example 36 | 45 | 46 | 47 | 48 |
49 |

Simple PHP Pagination Demo

50 | 51 | 52 | 53 |
54 |
55 | 65 |
66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 |
#FirstLastEmailDOB
91 | 92 | 93 | 112 |
113 | 114 | 115 | 116 | 117 | 124 | 125 | 126 | 127 | --------------------------------------------------------------------------------