PHP Classes

Paginator Kernel Web: Generate links to navigate paginated listings

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 120 This week: 1All time: 9,485 This week: 560Up
Version License PHP version Categories
paginator-kernel-web 1.1GNU General Publi...5HTML, PHP 5
Description 

Author

This class can generate links to navigate paginated listings.

It can take the total number of entries to display in a listing and generates links to navigate to the other pages of the listing, considering a given limit number of entries to display per page.

The current page number and the links base URL are taken from the current request URL parameters.

The class can also limit the number of navigation links to display.

Picture of Ruben Arroyo
  Performance   Level  
Name: Ruben Arroyo <contact>
Classes: 2 packages by
Country: Spain Spain
Age: 30
All time rank: 377099 in Spain Spain
Week rank: 411 Up13 in Spain Spain Up

Example

<?php
include 'paginator.php';

/*
 * To see all params to configure, please, open "paginator.php"
 * You can paginate ANYTHING you like (not only tables from database)
 */
// Its recomended have a count of all records of a table to count (if you use SQL or something)
// and pass directly total records

/*
 * EXAMPLE PART 1: Loading total records from database:
 * $records = mysql_num_rows(mysql_query("SELECT count(*) as tot FROM mytable WHERE YOUR_FILTER_OPTIONAL));
 */

/*
 * EXAMPLE PART 2: Paginating records
 */
$test = new Paginator(); // Init pagination
//$test->total_records = $records['tot']; // Records loaded from query
$test->total_records = 50; // Total records
$test->class = 'pagination'; // Specify div class
$test->specific_get = array();
$test->paginate(); // refresh and update all calcs and settings


echo $test->show(); // Showing all links

/*
 * EXAMPLE PART 3: loading results from database:
 * $records = mysql_query("SELECT * FROM mytable WHERE YOUR_FILTER_OPTIONAL $test->limit");
 *
 * while ($row = mysql_fetch_assoc($records)) {
 * echo $row['yourField'];
 * }
 */
echo '<br />';

echo
'First record of current page: '.$test->first_record.'<br />';
echo
'LIMIT to DB: '.$test->limit.'<br />';


  Files folder image Files  
File Role Description
Plain text file changelog.txt Data Changelog
Plain text file example.php Example Example
Plain text file Paginator.php Class Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:120
This week:1
All time:9,485
This week:560Up