PHP Classes

Paginator Kernel Web: Generate links to navigate paginated listings

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 120 All time: 9,502 This week: 206Up
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: 31
All time rank: 377599 in Spain Spain
Week rank: 192 Up6 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 (3)  
File Role Description
Plain text file changelog.txt Data Changelog
Plain text file example.php Example Example
Plain text file Paginator.php Class Class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:120
This week:0
All time:9,502
This week:206Up