Name Modified Size Downloads / Week Status
zebra_pagination.1.2.1.zip 2012-01-07 22.6 kB 11 weekly downloads
readme.md 2012-01-07 4.6 kB 0
zebra_pagination.1.1.zip 2011-03-20 22.5 kB 0
zebra_pagination.1.0.1.zip 2011-01-08 21.6 kB 0
Totals: 4 Items   71.3 kB 1

Zebra_Pagination, a generic pagination class written in PHP

A generic pagination class that automatically generates navigation links given the total number of items and the number of items per page.

Please note that this is a generic pagination class, meaning that it does not display any records! It is up to developer to fetch the actual data and displaying it based on the information returned by this class. The advantage is that it can be used to paginate over records coming from any source (arrays, database, etc).

The appearance is customizable through CSS.

Zebra_Pagination‘s code is heavily commented and generates no warnings/errors/notices when PHP’s error reporting level is set to E_ALL.


PHP 4.4.9+


Download the latest version, unpack it, and put it in a place accessible to your scripts.

How to use

Make sure that in the <head> of your page you have

<link rel="stylesheet" href="path/to/Zebra_Pagination/public/css/zebra_pagination.css" type="text/css">

Paginate data from an array:

// let's paginate data from an array...
$countries = array(
    // array of countries

// how many records should be displayed on a page?
$records_per_page = 10;

// include the pagination class
require 'path/to/Zebra_Pagination.php';

// instantiate the pagination object
$pagination = new Zebra_Pagination();

// the number of total records is the number of records in the array

// records per page

// here's the magick: we need to display *only* the records for the current page
$countries = array_slice(
    (($pagination->get_page() - 1) * $records_per_page),




    <?php foreach ($countries as $index => $country):?>

    <tr<?php echo $index % 2 ? ' class="even"' : '')?>>
        <td><?php echo $country?></td>

    <?php endforeach?>



// render the pagination links


Paginate data from MySQL:

// how many records should be displayed on a page?
$records_per_page = 10;

// include the pagination class
require 'path/to/Zebra_Pagination.php';

// instantiate the pagination object
$pagination = new Zebra_Pagination();

// the MySQL statement to fetch the rows
// note how we build the LIMIT
// also, note the "SQL_CALC_FOUND_ROWS"
// this is to get the number of rows that would've been returned if there was no LIMIT
// see http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
$MySQL = '
        ' . (($pagination->get_page() - 1) * $records_per_page) . ', ' . $records_per_page . '

// if query could not be executed
if (!($result = @mysql_query($MySQL))) {

    // stop execution and display error message


// fetch the total number of records in the table
$rows = mysql_fetch_assoc(mysql_query('SELECT FOUND_ROWS() AS rows'));

// pass the total number of records to the pagination class

// records per page


<table class="countries" border="1">


    <?php $index = 0?>

    <?php while ($row = mysql_fetch_assoc($result)):?>

    <tr<?php echo $index++ % 2 ? ' class="even"' : ''?>>
        <td><?php echo $row['country']?></td>

    <?php endwhile?>



// render the pagination links


Useful links

Documentation | Changelog | Comments

Source: readme.md, updated 2012-01-07

Thanks for helping keep SourceForge clean.

Screenshot instructions:
Red Hat Linux   Ubuntu

Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Briefly describe the problem (required):

Upload screenshot of ad (required):
Select a file, or drag & drop file here.

Please provide the ad click URL, if possible:

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks