Function, which automaticly prints a page-navigation, when there are more entries which are returned from dabase then should be printed on a page
By : klbecke
<?php
//*******************************************************************************
//
// Klaus Becker,
// kbecker@mbo-verlag.de
// Dezember 2000
//
// Function, which automaticly prints a page-navigation,
// when there are more entries which are returned from
// a database then should be printed on a page
//
//
// The function needs three parameter
//
// 1. allEntries: Integer, Number of all DB-Entries
// 2. limitBy: Integer, Number of Entries, which are printed on one Page
// 3. limitStart: Integer, Offset
//
//*******************************************************************************
function showPageNavigation($allEntries, $limitStart=0, $limitBy=20)
{
$lastPageEntries = ($allEntries % $limitBy);
$allPages = round(($allEntries - $lastPageEntries) / $limitBy)+1;
if($lastPageEntries>0 and $allPages==0) {$allPages=$allPages+1;}
$thisPage = round(($limitStart+$limitBy) / $limitBy);
print "<b><br>Page ".$thisPage." of ".$allPages."<br><br></b>";
if($allEntries > $limitBy)
{
print "<b>Pages:</b> ";
for($entryNr=1; $entryNr<=$allPages; $entryNr++)
{
$startPage = ($entryNr * $limitBy) - $limitBy;
if($thisPage!=$entryNr){print "<b><a href=\"".$PHP_SELF."?limitStart=".$startPage."\">".$entryNr."</a></b> ";}
else{print "<b>".$entryNr."</b> ";}
}
}
$startNext = $thisPage * $limitBy;
if($startNext < ($allPages * $limitBy) and $allEntries > $limitBy)
{print " <b><a href=\"".$PHP_SELF."?limitStart=".$startNext."\">next</a></b> ";}
}
?>
<?php
if(!isset($limitStart)){$limitStart = 0;}
showPageNavigation(130,$limitStart,20);
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Site Navigation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. FREE! Go There Now!
|
|
|
|
Build secure Web services with transport-level security using IBM Rational Application Developer V7 and IBM WebSphere Application Server V6.1. Follow this three-part series for step-by-step instructions about how to develop Web services and clients, configure HTTP basic authentication, and configure HTTP over SSL (HTTPS). This first part of the series walks you through building a Web service for a simple calculator application. You generate and test two different types of Web services clients: a Java Platform, Enterprise Edition (Java EE) client and a stand-alone Java client. You also handle user-defined exceptions in Web services. FREE! Go There Now!
|
|
|
|
Join us for this on demand webcast to learn about developing complex systems more quickly and efficiently. We'll cover market drivers for developing, governing and reusing systems software assets and how you can develop system software assets with Rational Asset Manager. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial version of Lotus Quickr 8.0, which enables collaboration by transforming the way everyday business content such as documents, rich media, photos, and video can be shared. Lotus Quickr makes it faster and easier to share content of all types (not just documents) within virtual teams. It is designed to make it easier to collaborate across organizational boundaries, while continuing to work within the context of familiar desktop applications. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly. FREE! Go There Now!
|
|
|
|
Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |