Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Site Navigation sample source codes
Show result with paging and staging
Show result with paging and staging 1) { $links.="
<<<</a> \n"; } if(trim($nowstage)>1) { $links.="
<<</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> \n"; } if(((($nowstage-1)*$pageperstage)+$i)==$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage) { $links=$links."
".((($nowstage-1)*$pageperstage)+$i)."</b> "; } if(((($nowstage-1)*$pageperstage)+$i)!=$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage) { $links=$links."
".((($nowstage-1)*$pageperstage)+$i)."</a> \n"; } if(($i==$endpage||$i==$allpage)&&$nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$allpage>$nowpage) { $links=$links."
></a> \n"; } } } if($nowstage<$allstage) { $links=$links. "
>></a> \n"; } if($nowpage<$allpage) { $links.="
>>></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;} ?>
Records result from query statement :
=$number;?></b> record.
Want to show
=$displayperpage;?></b> in every page.
Want to show only
=$pageperstage;?></b> page on every stage.
Then there would be
=$allpage;?></b> page of results.
And there would be
=$allstage;?></b> stage of pages.
PAGING</b> : =myPageNumber($nowstage,$startpage,$allpage,$nowpage,$pageperstage,$allstage);;?>
Stage</b> =$nowstage." of ".$allstage;?>
Page</b> =$nowpage." of ".$allpage;?>
".((($nowpage-1)*$displayperpage)+$i); } ?> </font>
Privacy Policy
|
Link to Us
|
Links