PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of rafi randoni  >  PHP Array Paging  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: PHP Array Paging
Generate pagination links for listings in an array
Author: By
Last change:
Date: 6 years ago
Size: 1,818 bytes
 

Contents

Class file image Download
<?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();
?>

For more information send a message to info at phpclasses dot org.