Navigation Usability
  Home arrow Navigation Usability arrow Page 5 - Using Multiple Pages for Navigation
IBM developerWorks
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
NAVIGATION USABILITY

Using Multiple Pages for Navigation
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2002-09-08

    Table of Contents:
  • Using Multiple Pages for Navigation
  • Recap
  • Setting up variables
  • Displaying links
  • Final Script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Using Multiple Pages for Navigation - Final Script


    (Page 5 of 5 )

    Now we should have a fully functional navigation system. You might want to add some extra characters to enhance the appearace - I'll put a few in the final script. Note that everything in this tutorial is in between the stars and the rest is notepad's original script. If you've followed along, below is the complete script. I hope you've found it useful. Hopefully, the next tutorial will cover how to modify the news system to make it a more secure, dynamic, truly useful system.

    <?php
    // if a page isn't defined, we're on page one
    if($page &lt;= 0)
    {
        
    $page 1;
    }

    // create an array of data
    $myArray file("data.txt");

    // reverse the order of the data
    $myArray array_reverse($myArray);

    // how many lines of data to display
    $display 5;

    // where to start depending on what page we're viewing
    $start = ($page $display) - $display;

    /*********************************************************/
        
    $realstart = ($start 1); 
    $finish = ($start $display);
    $keys count($data);
    $newspages = ($keys 10); 
    if (
    $finish &gt$keys) { 
        
    $finish $keys; }

        if (
    $page &gt1) {
    ?&
    gt;
        &
    lt;&lt; &lt;a href="&lt;?=$PHP_SELF;?&gt;?page=&lt;?=($page - 1);?&gt;"&gt;previous&lt;/a&gt; ||
    &
    lt;?php }
        echo 
    "displaying items " $realstart " through " $finish;
        if (
    $page &lt$newspages) {
    ?&
    gt;
        || &
    lt;a href="&lt;?=$PHP_SELF;?&gt;?page=&lt;?=($page + 1 );?&gt;"&gt;next&lt;/a&gt; &gt;&gt;
    &
    lt;?php 
        echo 
    "&lt;br /&gt;" $keys " items total"
        
    /*********************************************************/

    // the actual news we're going to print
    $news array_slice($myArray$start$display);

    // printing the data
    foreach($news as $key=&gt;$value)
    {
        print(
    "line $key: $value&lt;br&gt;\n");
    }
    ?>


    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.

       · I think there was a mistake in this tutorial, because it didn't work for me until I...
       · Fixed, and now working fine. :)[code]<?PHP$page = $_GET['page'];// if a...
       · << previous ||displaying 26 - 30 of 54The script displays only 30 of the 54...
     

    NAVIGATION USABILITY ARTICLES

    - Advanced Bulleted-List Menu
    - Using Multiple Pages for Navigation






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway