PHP Classes

File: examples/pagination/example_standalone.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/pagination/example_standalone.php   Download  
File: examples/pagination/example_standalone.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 1,635 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Skeleton - Pagination example - basic</title>
</head>
<body>
<?php
include 'config.php';
include
dirname(__FILE__) . '/../../A/autoload.php';

// initialize an array for testing
for ($i=0; $i<=750; ++$i) {
   
$myarray[$i]['title'] = 'This is row ' . $i;
   
$myarray[$i]['month'] = date ('F', time() + ($i * 60 * 60 * 24 * 30));
}
#$myarray = null;
// create a data object that has the interface needed by the Pager object
$datasource = new Datasource($myarray);

// create a request processor to set pager from GET parameters
$pager = new A_Pagination_Standalone($datasource);
$pager->setRangeSize(3)->process();

$rows = $pager->getItems();

// display the paging links ... should this go in a template?
$links = '';
$links .= $pager->link()->previous('Previous');
$links .= $pager->link()->first();
$links .= $pager->link()->range();
$links .= $pager->link()->last();
$links .= $pager->link()->next('Next');

echo
"<div>$links</div>";

// display the data
echo '<table border="1">';
echo
'<tr><th><a href="' . $pager->url()->render (false, array ('order_by' => '')) . '">Row</a></th><th><a href="' . $pager->url()->render (false, array ('order_by' => 'title')) . '">Title</a></th><th><a href="' . $pager->url()->render (false, array ('order_by' => 'month')) . '">Month</a></th></tr>';
$n = 1;
foreach (
$rows as $value) {
    echo
'<tr>';
    echo
'<td>' . $n++ . '.</td><td>' . $value['title'] . '</td><td>' . $value['month'] . '</td>';
    echo
'</tr>';
}
echo
'</table>';

echo
"<div>$links</div>";

#dump($pager);
?>
<p/>
<a href="../">Return to Examples</a>
</p>

</body>
</html>