PHP Classes
elePHPant
Icontem

Simple PHP Pagination Class: Display paginated database table records

Recommend this page to a friend!
  Info   View files Example   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-08-22 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 363 This week: 3All time: 6,611 This week: 228Up
Version License PHP version Categories
simplephppagination 1.0.1BSD License5HTML, PHP 5, Databases
Description Author

This class can display paginated database table records.

It takes a PDO object and performs queries to retrieve records for a given database table.

The class can generate pagination links to browse the results with a limited number of records per page.

Name: NoobSaiboT TheFreakative ... <contact>
Classes: 1 package by
Country: Nigeria Nigeria
Age: ???
All time rank: 347218 in Nigeria Nigeria
Week rank: 231 Up4 in Nigeria Nigeria Up

Details

<p align="center"> <img align="center" src="pag.png" width="100%" alt="pagination sample"/> </p>

Simple Pagination Class

This is a simple class that implements pagination when connected to a mysql databse via PDO.

- Include the class - Set the name of your table, number of items per page - edit the ouputted html however you want and voila !

It is really easy to set up. No hassle or stress.

Requirements

To work properly, the class needs:

  • PHP 5 and above, (tested on PHP 7 but should work flawlessly on PHP 5)
  • Web server with PHP and mySQL installed

Installation

This class requires PHP 5 + to run.

Download and extract (https://github.com/sayopaul/paginationclass).

Set your config.php file

<?php
	//set your database comnfiguration here. Ensure to fill in the username and password if there is any.
	define("DSN","mysql:host=dbhost;dbname=dbname");
	define("USER","username");
	define("PASS","password");

After that, you create a new PDO object with the config details

<?php
		//!important ---- require the config file and the Pagination class
		require "config.php";
		include "Pagination.class.php";
		//initialize PDO connection and save object to $db
		try{
			$db=new PDO(DSN,USER,PASS);
		}catch(PDOException $e){
			echo "could not connect because of " .$e ;
		}
		//pass the pdo object,the number of listings per page, and the table name to the class. 
		$paginate = new Pagination($db,5,"customers");
		//call the paginate methods
		$test =$paginate->paginate();
		//print out the returned result
		echo $test;

There's a test file using bootstrap that shows a proper example

Development

Want to contribute? Great! Please star and help to identify areas to improve. Thanks

License

MIT

Free Software, Hell Yeah!

  Files folder image Files  
File Role Description
Files folder imagecss (1 file)
Accessible without login Plain text file config.php Conf. Configuration script
Accessible without login Plain text file database.sql Data Auxiliary data
Accessible without login Plain text file orders.php Example Example script
Accessible without login Image file pag.png Data Auxiliary data
Plain text file Pagination.class.php Class Class source
Accessible without login Plain text file readme.md Doc. Documentation
Accessible without login Plain text file test.php Example Example script

  Files folder image Files  /  css  
File Role Description
  Accessible without login Plain text file bootstrap.min.css Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:363
This week:3
All time:6,611
This week:228Up
User Comments (1)