phpPagination Source code of phppagination/example2.php


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<head><title>phpPagination: Example 2: list of pagination output</title></head>
<html><body>
<?php

require_once('phppagination.class.php');

$nTotalItems 555;
$nItemsPerPage 15;

// redefine output for first and last elements
$aOptions['first'] = '<a href="__PHP_SELF__?page=__PAGE_NUMBER__">First</a>';
$aOptions['last'] = '<a href="__PHP_SELF__?page=__PAGE_NUMBER__">Last</a>';

// define pagination prefix and suffix
$aOptions['prefix'] = '<table border="1"><tr><td>';
$aOptions['suffix'] = '&nbsp;(page __CURRENT_PAGE__ of __TOTAL_PAGES__)'
    
.'</td></tr></table>';

// create pagination object
$oPagination = new phpPagination ($nTotalItems$nItemsPerPage$aOptions );

// print pagination output for all pages
$iTotalPages $oPagination->GetTotalPages();
for (
$nPage 1$nPage <= $iTotalPages;  $nPage++)
{
    
// get HTML-code for $nPage
    
$sPaginationHtml $oPagination->GetHtml($nPage);
    
// print pagination
    
echo $sPaginationHtml."<br />\n";
}
?>
</body></html>
back
sourceforge.net freshmeat.net