PHP Pagination with Search Functionality

Posted on

Overview

Not long ago I was working on a website that needed pagination (like most things I build) so I came up with this code. It is easy to use and can be set up and running in a matter of minutes. You tell it what table to pull from, what to pull from it and how many you want to display. That simple! It even includes an optional search functionality which is also very simple to use. You can download it below, it comes with a readme file explaining exactly how to use it and the pagination script itself. Whats extra special about this pagination script is that you have total control of how the pagination links look. They can be styles in hundreds of ways that I found was a problem for other pagination scripts.

Just a Preview

function init(){
		$this->startTime = microtime();
		$this->start = ($this->current_page - 1)*$this->items_per_page;
		$this->buildQuery();
		$this->runQuery();
		$this->total_items = mysql_num_rows($this->pre);
		$this->total_pages = ceil($this->total_items/$this->items_per_page);
		$this->makeNav();
		$this->timeEnd = microtime();
		$this->duration = $this->timeEnd - $this->startTime;
	}

Download

You are more than welcome to use this code in any of your projects just be sure to give me credit where called for. You can use this in personal and commercial projects.

If you have any issues with the code please let me know in the comments below. I would like to improve this code as I love to solve problems and give back to the community.

Thanks! Enjoy
Paginator Script

Change Log

  1. First Version Released

This script is not affiliated with Google in any way

  • L983

    i need this script and downloaded the demo also. But cannot understand something. could you please upload or define more details with search functionality and pagination with step by step .. thanks in advance

  • matt

    Hey nice work but, its not displaying my results? using wamp5 

  • http://zackperdue.com Zack Perdue

    Your results are completely separate, and my pagination has nothing to do with the results.