Pagination - Site Navigation for Displaying Large Data

Nov 4, 2008 | Tags: PHP | del.icio.us del.icio.us | digg Digg

This is a simple function to create pagination links; what would you need when you split large data into several pages. The function is very simple and easy to customize. It takes 4 arguments and you called it like this:

Listing 1: Usage is simple

  1. <div id="pagination">
  2.   <?php  
  3.     clean_pagination($total_rows,  
  4.                      $entries_per_page,  
  5.                      $current_page,  
  6.                      $link_to);  
  7.   ?>
  8. </div>

It will produce clean HTML in several DIVs like this:

Listing 2: HTML result

  1. <div id="pagination">
  2.         <div><a href="products.php?cat=dvd&amp;page=1">Prev</a></div>
  3.         <div><a href="products.php?cat=dvd&amp;page=1">1</a></div>
  4.         <div class="current-page">2</div>
  5.         <div><a href="products.php?cat=dvd&amp;page=3">3</a></div>
  6.         <div><a href="products.php?cat=dvd&amp;page=4">4</a></div>
  7.         <div><a href="products.php?cat=dvd&amp;page=3">Next</a></div>
  8. </div>

So you can control its appearance by using CSS in any way you like.

The Downloads

2 Comments

mahmood namvar on Oct 4, 2009:

thats very good.
thaaaaaaaaaaaaaaaaanks

shiv on Mar 11, 2010:

very helpful for us

Leave a comment

Name (required)
Email (will not be published) (required)
Website

Characters left = 1000

Tags

Recent Posts

  1. OpenCV Utility: Reading Image Pixels Value
  2. OpenCV Circular ROI
  3. OpenCV 2.0 Installation on Windows XP and Visual Studio 2008
  4. Runtime ROI Selection using Mouse
  5. Real Time Eye Tracking and Blink Detection
View Archives

About the Author

avatar Cool PHP programmer writing cool PHP scripts. Feel free to contact
Tel. +62 31 8662872
+62 856 338 6017
ICQ 489571630
Skype dede_bl4ckheart
Yahoo dede_bl4ckheart
Google nashruddin.amin

Recommended Sites:

Hacker's HTTP Client
HTML and CSS Tutorials
Stop Dreaming Start Action
Online Quran and Translation