Navigation Usability

  Home arrow Navigation Usability arrow Page 5 - Using Multiple Pages for Navigation
NAVIGATION USABILITY

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

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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    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.
    blog comments powered by Disqus

    NAVIGATION USABILITY ARTICLES

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


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