Site Navigation Code

  Home arrow Site Navigation Code arrow show result with paging and staging
SITE NAVIGATION CODE

show result with paging and staging
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    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.="&nbsp;<a href='$PHP_SELF?nowstage=1&nowpage=1'>&lt;&lt;&lt;</a>&nbsp;\n";
    }
    if(trim($nowstage)>1)
    {
    $links.="&nbsp;<a href='$PHP_SELF?nowstage=".($nowstage-1)."&nowpage=".((($nowstage-1)*$pageperstage)-($pageperstage-1))."'>&lt;&lt;</a>&nbsp;\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."&nbsp;<a href='$PHP_SELF?nowstage=$nowstage&nowpage=".($nowpage-1)."'>&lt;</a>&nbsp;\n";
    }
    if(((($nowstage-1)*$pageperstage)+$i)==$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
    {
    $links=$links."&nbsp;<b>".((($nowstage-1)*$pageperstage)+$i)."</b>&nbsp;";
    }
    if(((($nowstage-1)*$pageperstage)+$i)!=$nowpage&&((($nowstage-1)*$pageperstage)+$i)<=$allpage)
    {
    $links=$links."&nbsp;<a href='$PHP_SELF?nowstage=$nowstage&nowpage=".((($nowstage-1)*$pageperstage)+$i)."'>".((($nowstage-1)*$pageperstage)+$i)."</a>&nbsp;\n";
    }
    if(($i==$endpage||$i==$allpage)&&$nowpage!=((($nowstage-1)*$pageperstage)+$i)&&$allpage>$nowpage)
    {
    $links=$links."&nbsp; <a href='$PHP_SELF?nowstage=$nowstage&nowpage=".($nowpage+1)."'>&gt;</a>&nbsp;\n";
    }
    }
    }
    if($nowstage<$allstage)
    {
    $links=$links. "&nbsp;<a href='$PHP_SELF?nowstage=".($nowstage+1)."&nowpage=".(($nowstage*$pageperstage)+1)."'>&gt;&gt;</a>&nbsp;\n";
    }
    if($nowpage<$allpage)
    {
    $links.="&nbsp;<a href='$PHP_SELF?nowstage=".$allstage."&nowpage=".$allpage."'>&gt;&gt;&gt;</a>&nbsp;\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

    blog comments powered by Disqus

    SITE NAVIGATION CODE ARTICLES

    - Simple Menu System
    - Simply image viewer script
    - Simple File Lister
    - Dynamic Error Pages
    - BSoftEditor
    - Yahoo Status
    - Page numbers
    - PHP Search Navigator 1.0
    - Simple Page Navigation
    - An easy page browser ( prev 6 7 8 9 10 next )
    - AutoIndex PHP Script (Directory Indexer)
    - Bs_HtmlNavigation (Navigation and Sitemap cl...
    - Another Paging with Stage
    - Website Navigation via PHP
    - MySQL Paging Class


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap