PHP Pagination

This is a guide how to create a pagination using PHP and MySQL.

Overview

This is a script to make pagination in PHP like digg.com or flickr.com. This script was written by a guy from Stranger Studios.

In this page I've edit the script a little bit to make it working and easy to edit. You can grab the original script at Digg-Style Pagination.

My tutorial is just a guide how to implemente in your PHP script. The image below is what you'll get after finished this code.

PHP Pagination Script

STEP1: The Code

Grab the code and paste in your text editor.
You have to customize 7 spots in this code (see images below).

1. Code to connect to your DB - place or include your code to connect to database.
2. $tbl_name - your table name.
3. $adjacents - how many adjacent pages should be shown on each side.
4. $targetpage - is the name of file ex. I saved this file as pagination.php, my $targetpage should be "pagination.php".
5. $limit - how many items to show per page.
6. "SELECT column_name - change to your own column.
7. Replace your own while..loop here - place your code to echo results here.

After all, save and test your script.

############### Code


These are where you have to customize the script
PHP pagination PHP pagination

STEP2: Apply CSS Style to your code

Save this code to style.css and link to your pagination page.
To get more CSS style click here

PHP pagination



Similar Post

Upload and Rename File

In this tutorial show you how to rename file when upload file to server to prevent new file overwrite an old file that exists in you server.

PHP Redirection script

Learn how to redirect in this tutorial, you can use header(); function in php or use meta to redirect to a new page you want or redirect to other website.