PHP Classes

PHP Array Paging: Generate pagination links for listings in an array

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 70%Total: 812 This week: 1All time: 4,243 This week: 560Up
Version License PHP version Categories
array-paging 1.1.2GNU General Publi...5.3HTML, PHP 5
Description 

Author

This class can generate pagination links for listings in an array.

It takes a list of items to display in an array and generates links to browse the the previous and next pages that will list the items.

The current page number is retrieved from a request parameter. The limit number of items to display per page is configurable.

Picture of rafi randoni
  Performance   Level  
Name: rafi randoni <contact>
Classes: 2 packages by
Country: Indonesia Indonesia
Age: ???
All time rank: 194526 in Indonesia Indonesia
Week rank: 416 Up7 in Indonesia Indonesia Up

Recommendations

MySQL Pagination
Pagination for MySQL queries

Example

<?php
/*
* =============================
* Array Paging |
* -----------------------------
* -----------------------------
* Example
* -----------------------------
* =============================
*/

/*
* Templates Config :
* --------------------------------------------------------------------------
* <ul> :: Full Tag
* <li> :: Num Tag || Disabled Tag || Active Tag
* <a href="">Links</a>
* </li> :: Num Tag Close
* </ul> :: Full Tag Close
*/


/* Include library */
require_once 'ArrayPaging.php';


/* Data for paging */
$data = array(
       
0 => array(
               
'name' => 'A',
               
'address' => 'Address_A',
            ),
       
1 => array(
               
'name' => 'B',
               
'address' => 'Address_B',
            ),
       
2 => array(
               
'name' => 'C',
               
'address' => 'Address_C',
            ),
       
3 => array(
               
'name' => 'D',
               
'address' => 'Address_D',
            ),
    );


/*
* ===============================================
* Examples 1
* ===============================================
*/
/* Simple Paging */
$paging = new Paging($data, array('limit'=>2));
$page = (isset($_GET['page']) ? $_GET['page'] : 1);
$paging->setPage($page);

echo
'<pre>';
var_dump($paging->getData());
echo
$paging->getLinks();


/*
* ===============================================
* Examples 2
* ===============================================
*/
/* Paging With Own Template */
$options = array(
   
'full_tag' => '<div class="paging">',
   
'num_tag' => '<span>',
   
'active_tag' => '<span class="active">',
   
'disabled_tag' => '<span class="disabled">',
   
'limit' => 2,
);
$paging2 = new Paging($data, $options);
$page2 = (isset($_GET['page']) ? $_GET['page'] : 1);
$paging2->setPage($page2);

echo
'<pre>';
var_dump($paging2->getData());
echo
$paging2->getLinks();
?>


  Files folder image Files  
File Role Description
Plain text file ArrayPaging.php Class ArrayPaging Class
Accessible without login Plain text file example.php Example example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:812
This week:1
All time:4,243
This week:560Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:-
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:70%StarStarStarStar
Rank:295
 
This is a very good and useful class ;-)
9 years ago (José Filipe Lopes Santos)
70%StarStarStarStar