You have a query results number about 100000 record, then what you should do to view all of them ?, paging ?...yah good, but how many page would it shown in your page if every page is only view 100 record ? 1000 link page ? get real!!!.
By : hermawan
<?php
/*
* myPageNumber Function
* Author : Hermawan Haryanto
* Create date : 02/02/2001
* Update date : 03/20/2001
*/
Function myPageNumber($nowstage,$startpage,$allpage,$nowpage,$pageperstage,$allstage)
{
if(trim($nowpage)>1)
{
$links.=" <a href='$PHP_SELF?nowstage=1&nowpage=1'><<<</a> \n";
}
if(trim($nowstage)>1)
{
$links.=" <a href='$PHP_SELF?nowstage=".($nowstage-1)."&nowpage=".((($nowstage-1)*$pageperstage)-($pageperstage-1))."'><<</a> \n";
}
for($i=$startpage;$i<=$allpage;$i++)
{
if(trim($nowpage)=="")
{
$nowpage=$startpage;
}
$endpage=(($startpage+$pageperstage)-1);
if($i>=$startpage&&$i<=$endpage&&$i<=$allpage)
{
if($nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$i==$startpage&&$nowpage>$startpage)
{
$links=$links." <a href='$PHP_SELF?nowstage=$nowstage&nowpage=".($nowpage-1)."'><</a> \n";
}
if(((($nowstage-1)*$pageperstage)+$i)==$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
{
$links=$links." <b>".((($nowstage-1)*$pageperstage)+$i)."</b> ";
}
if(((($nowstage-1)*$pageperstage)+$i)!=$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
{
$links=$links." <a href='$PHP_SELF?nowstage=$nowstage&nowpage=".((($nowstage-1)*$pageperstage)+$i)."'>".((($nowstage-1)*$pageperstage)+$i)."</a> \n";
}
if(($i==$endpage||$i==$allpage)&&$nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$allpage>$nowpage)
{
$links=$links." <a href='$PHP_SELF?nowstage=$nowstage&nowpage=".($nowpage+1)."'>></a> \n";
}
}
}
if($nowstage<$allstage)
{
$links=$links. " <a href='$PHP_SELF?nowstage=".($nowstage+1)."&nowpage=".(($nowstage*$pageperstage)+1)."'>>></a> \n";
}
if($nowpage<$allpage)
{
$links.=" <a href='$PHP_SELF?nowstage=".$allstage."&nowpage=".$allpage."'>>>></a> \n";
}
return $links;
}
$number="100"; // record results selected from database
$displayperpage="5"; // record displayed per page
$pageperstage="5"; // page displayed per stage
$allpage=ceil($number/$displayperpage); // how much page will it be ?
$allstage=ceil($allpage/$pageperstage); // how many page will it be ?
if(trim($startpage)==""){$startpage=1;}
if(trim($nowstage)==""){$nowstage=1;}
if(trim($nowpage)==""){$nowpage=$startpage;}
?>
<font face=tahoma size=2>
Records result from query statement : <b><?=$number;?></b> record.<br>
Want to show <b><?=$displayperpage;?></b> in every page.<br>
Want to show only <b><?=$pageperstage;?></b> page on every stage.<br>
Then there would be <b><?=$allpage;?></b> page of results.<br>
And there would be <b><?=$allstage;?></b> stage of pages.<br><br>
<b>PAGING</b> : <?=myPageNumber($nowstage,$startpage,$allpage,$nowpage,$pageperstage,$allstage);;?><br>
<b>Stage</b> <?=$nowstage." of ".$allstage;?><br><b>Page</b> <?=$nowpage." of ".$allpage;?><br>
<?php
for($i=1;$i<=$displayperpage;$i++)
{
echo "<br>".((($nowpage-1)*$displayperpage)+$i);
}
?>
</font>
| 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! |
Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance. 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!
|
|
|
|
Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration. FREE! Go There Now!
|
|
|
|
Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today. FREE! Go There Now!
|
|
|
|
Portfolio Management is about effectively managing portfolio value by aligning portfolio investments with business goals. This complimentary e-kit provides a collection of materials that can help you understand how IBM Rational enables and automates best practices for improved governance and clear visibility into portfolio and project performance across the entire IT project lifecycle. FREE! Go There Now!
|
|
|
|
Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. 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!
|
|
|
|
All FREE IBM® developerWorks Tools! |