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.