learncodeweb / php-pagination-class-with-bootstrap-4
Fashion Bootstrap landing page for beginners.
Package info
github.com/LearnCodeWeb/PHP-pagination-class-with-Bootstrap-4
Type:php-pagination-class-with-bootstrap-4
pkg:composer/learncodeweb/php-pagination-class-with-bootstrap-4
dev-master
2026-06-08 09:21 UTC
Requires
- composer/installers: 1.*
This package is auto-updated.
Last update: 2026-06-08 09:21:32 UTC
README
A lightweight and easy-to-use PHP pagination class fully compatible with Bootstrap 4. This package helps developers paginate large datasets and display responsive pagination controls with minimal setup.
Features
- Bootstrap 4 compatible pagination
- Easy integration with PHP & MySQL
- Custom items per page support
- Jump menu navigation
- Responsive pagination links
- Lightweight and reusable class
Requirements
- PHP 5.6+
- MySQL Database
- Bootstrap 4
Installation
Using Composer
composer require learncodeweb/php-pagination-class-with-bootstrap-4:dev-master
Manual Installation
- Download the repository.
- Extract files into your project directory.
- Include the pagination class in your PHP file.
include_once('paginator.class.php');
Database Configuration
Create a database connection file (config.php).
<?php define('DB_NAME', 'test'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_HOST', 'localhost'); $db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if ($db->connect_error) { die("Connection failed: " . $db->connect_error); } ?>
Basic Usage
Include required files:
<?php include_once('config.php'); include_once('paginator.class.php'); ?>
Initialize pagination:
$pages = new Paginator(); $pages->default_ipp = 15; $query = $db->query("SELECT * FROM countries"); $pages->items_total = $query->num_rows; $pages->mid_range = 9; $pages->paginate();
Fetch paginated records:
$result = $db->query( "SELECT * FROM countries ORDER BY countryName ASC " . $pages->limit );
Display Pagination
<?php echo $pages->display_pages(); echo $pages->display_items_per_page(); echo $pages->display_jump_menu(); ?>
Example Table
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Country</th>
<th>Code</th>
</tr>
</thead>
<tbody>
<?php while($row = $result->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['countryName']; ?></td>
<td><?php echo $row['countryCode']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
Available Methods
| Method | Description |
|---|---|
paginate() |
Generate pagination |
display_pages() |
Display page links |
display_items_per_page() |
Display items per page selector |
display_jump_menu() |
Display jump menu |
limit |
SQL LIMIT clause |
Configuration Options
| Property | Description |
|---|---|
default_ipp |
Items per page |
items_total |
Total records |
mid_range |
Number of pagination links shown |
Example:
$pages->default_ipp = 20; $pages->mid_range = 7;
Project Structure
project/
│
├── config.php
├── index.php
├── paginator.class.php
└── assets/
License
MIT License