PHP Classes

Simple PHP Pagination Class: Display paginated database table records

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 618 This week: 1All time: 5,050 This week: 192Up
Version License PHP version Categories
simplephppagination 1.0.2BSD 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.

Picture of NoobSaiboT TheFreakative (iTs)
Name: NoobSaiboT TheFreakative ... <contact>
Classes: 1 package by
Country: United States United States
Age: ???
All time rank: 2966398 in United States United States
Week rank: 205 Up20 in United States United States Up


<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.


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


This class requires PHP 5 + to run.

Download and extract (

Set your config.php file

	//set your database comnfiguration here. Ensure to fill in the username and password if there is any.

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

		//!important ---- require the config file and the Pagination class
		require "config.php";
		include "Pagination.class.php";
		//initialize PDO connection and save object to $db
			$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


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



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 Image file pag.png Data Auxiliary data
Plain text file Pagination.class.php Class Class source
Accessible without login Plain text file 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  
This week:1
All time:5,050
This week:192Up
User Comments (1)
For more information send a message to info at phpclasses dot org.