This is a simple PHP library for easy pagination in PHP.
- Clone the repository or download the ZIP file.
git clone https://github.com/xentixar/easy_pagination_in_php.git
- Configure database in database.php inside config directory.
private $database_name = 'your_database_name';
- Include autoload.php file in your file
require_once __DIR__ . '/autoload.php';
- Fetch data from table or from any other source as array.
For example:
$data = [
'data_1','data_2','data_3'
];
- Adjust the
$limit
variable in the PHP script to control the number of records displayed per page.
$limit = 10;
- Create an instance of the Pagination class and pass data and limit to it.
$paginator = new Pagination($data, $limit);
- Get the paginated data using the paginate method.
$paginated_data = $paginator->paginate();
- View the pagination links using the links method.
$paginator->links();
Check the example directory for sample usage of the pagination library.
- Fork the repository.
- Create a new branch: git checkout -b feature-name.
- Commit your changes: git commit -m 'Add new feature'.
- Push to the branch: git push origin feature-name.
- Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.