Site Navigation Code

  Home arrow Site Navigation Code arrow Simple Page Navigation
SITE NAVIGATION CODE

Simple Page Navigation
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2003-03-25

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    Create links to all pages in an array without the use of SQL. Puts in prev/next images and a "here"-image by comparing the pagenumber with the array. The files have to be named file_1.php, file_2.php, file_3.php, etc.

    By : Reptilian Felin

    [PHP]
    <?php
    //This script is created by Reptilian Feline
    //www.reptilian-feline.net
    //If you use it, please link to my site
    $full_path = getenv("REQUEST_URI");
    //put the base URL in case you need it
    $base = "http://subomain.domain.ext";
    //Get the name of the file
    $page_file = basename($full_path);
    //The files are named file_1.php, file_2.php, etc. Extract number from it.
    $page_num = substr($page_file
    , strrpos($page_file, "_") + 1
    , strpos($page_file, ".php") - strrpos($page_file, "_") - 1
    );
    $partial_path = substr($page_file, 0, strrpos($page_file, "_"));
    //Build array of pagenumbers. Here are ten pages.
    $all_pages = array (1,2,3,4,5,6,7,8,9,10);

    foreach ($all_pages as $all_page)
    {
    //Create link to all the previus pages and put in prev-image.
    if ($all_page < $page_num)
    {
    print "<a href=\"$partial_path"."_". $all_page . ".php\"><img src=\"images/prev.gif\" alt=\"$all_page\" border=\"0\"></a>";
    }
    //Create I-am-here-image.
    elseif ($all_page == $page_num)
    {
    print "<img src=\"images/here.gif\" alt=\"$page_num\" border=\"0\">";
    }
    //Create links to all the next pages and put in next-image.
    else
    {
    print "<a href=\"$partial_path"."_" . $all_page . ".php\"><img src=\"images/next.gif\" alt=\"$all_page\" border=\"0\"></a>";
    }
    }
    ?>
    [/PHP]
    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