Site Navigation Code

  Home arrow Site Navigation Code arrow Another Paging with Stage
SITE NAVIGATION CODE

Another Paging with Stage
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-11-11

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This script is not actually a class. I just want to show you how to make paging with result set and how to display it not all of the link page, but separate it in some number of stage.

    By : hermawan

    <?php
    class paging {
    function paging () {
    $this->rowperpage = 50;
    $this->pageperstg = 20;
    }
    function getPaging($rownum, $pg="1", $stg="1") {
    $arr = explode("&",$_SERVER["QUERY_STRING"]);
    if (is_array($arr)) {
    for ($i=0;$i<count($arr);$i++) {
    if (!is_int(strpos($arr[$i],"pg=")) && !is_int(strpos($arr[$i],"stg=")) && trim($arr[$i]) != "") $qs .= $arr[$i]."&";
    }
    }
    if ($this->rowperpage<$rownum) {
    $allpage = ceil($rownum/$this->rowperpage);
    $allstg = ceil($allpage/$this->pageperstg);
    $minpage = (($stg-1)*$this->pageperstg)+1;
    $maxpage = $stg*$this->pageperstg;
    if ($maxpage>$allpage) $maxpage = $allpage;
    if ($allpage>1) {
    $rtn = "<table width=100% align=center cellpadding=2 cellspacing=0><tr align=center valign=middle><td class=\"smallbody\">";
    if ($stg>1) $rtn .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($minpage-1)."&stg=".($stg-1)."\">Previous Stage</a> | ";
    if ($pg>1) {
    if ($pg==$minpage) {
    $rtn .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($pg-1)."&stg=".($stg-1)."\">Previous</a> | ";
    } else {
    $rtn .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($pg-1)."&stg=$stg\">Previous</a> | ";
    }
    }
    for ($i=$minpage;$i<=$maxpage;$i++) {
    if ($i==$pg) {
    $rtn .= "<b>$i</b> | ";
    } else {
    $rtn .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=$i&stg=$stg\" title='Page $i'>$i</a> | ";
    }
    }
    if ($pg<=$maxpage) {
    if ($pg==$maxpage && $stg<$allstg) {
    $rtn .= " <a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($pg+1)."&stg=".($stg+1)."\">Next</a> | ";
    } elseif ($pg<$maxpage) {
    $rtn .= " <a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($pg+1)."&stg=$stg\">Next</a> | ";
    }
    }
    if ($stg<$allstg) $rtn .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$qs."pg=".($maxpage+1)."&stg=".($stg+1)."\">Next Stage</a> | ";
    $rtn = substr($rtn,0,strlen($rtn)-3);
    $rtn .= "</td></tr></table>";
    return $rtn;
    }
    }
    }
    };
    ?>
    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

    Developer Shed Affiliates

     



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