Site Navigation Code

  Home arrow Site Navigation Code arrow Navigation through a page-list, which ...
SITE NAVIGATION CODE

Navigation through a page-list, which is returned by a Database
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    Function, which automaticly prints a page-navigation, when there are more entries which are returned from dabase then should be printed on a page

    By : klbecke

    <?php

    //*******************************************************************************
    //
    // Klaus Becker,
    // kbecker@mbo-verlag.de
    // Dezember 2000
    //
    // Function, which automaticly prints a page-navigation,
    // when there are more entries which are returned from
    // a database then should be printed on a page
    //
    //
    // The function needs three parameter
    //
    // 1. allEntries: Integer, Number of all DB-Entries
    // 2. limitBy: Integer, Number of Entries, which are printed on one Page
    // 3. limitStart: Integer, Offset
    //
    //*******************************************************************************

    function showPageNavigation($allEntries, $limitStart=0, $limitBy=20)
    {
    $lastPageEntries = ($allEntries % $limitBy);
    $allPages = round(($allEntries - $lastPageEntries) / $limitBy)+1;
    if($lastPageEntries>0 and $allPages==0) {$allPages=$allPages+1;}
    $thisPage = round(($limitStart+$limitBy) / $limitBy);
    print "<b><br>Page ".$thisPage." of ".$allPages."<br><br></b>";
    if($allEntries > $limitBy)
    {
    print "<b>Pages:</b>&nbsp;";
    for($entryNr=1; $entryNr<=$allPages; $entryNr++)
    {
    $startPage = ($entryNr * $limitBy) - $limitBy;
    if($thisPage!=$entryNr){print "<b><a href=\"".$PHP_SELF."?limitStart=".$startPage."\">".$entryNr."</a></b>&nbsp;";}
    else{print "<b>".$entryNr."</b>&nbsp;";}
    }
    }
    $startNext = $thisPage * $limitBy;
    if($startNext < ($allPages * $limitBy) and $allEntries > $limitBy)
    {print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><a href=\"".$PHP_SELF."?limitStart=".$startNext."\">next</a></b>&nbsp;";}
    }
    ?>

    <?php
    if(!isset($limitStart)){$limitStart = 0;}
    showPageNavigation(130,$limitStart,20);
    ?>
    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 5 - Follow our Sitemap