You are seeing this very light version of the page, as you are using an outdated browser!

Onlinetools.org is done in XHTML 1.0 and supports CSS 2.0, please upgrade your browser if you want a better version of this site.

Thank you, please help us developers keep up with the industry rather than patching our code for outdated applications.

open or close right navigation

Previous and Next links demystified

Advertisement:
 
written by:Christian Heilmann on 12.05.2002
Jump to page: 1  2  3  or read all on one page
 

The whole script

Here's the whole script for copy and paste.


<?php
    $start=$HTTP_GET_VARS['start'];
    // Populate the demo array
    $i=0;while ($i<=24){$entries[]=$i;$i++;}

    // the number of items displayed on one screen.
    $increase=5;    
    // if there is no start value set, set start to 0
    if(!$start){$start=0;}
    // end of display is start plus increase
    $end=$start+$increase;
    
    // If start is equal or bigger than increase, display the previous
    // link, which sets start to start-increase
    if ($start >= $increase){
    echo "<a href=\"".$HTTP_SERVER_VARS['PHP_SELF']."?start=".($start-$increase)."\">previous</a>&#160;";
    }
    // take the part of the entries in between start and start*increase and display it
    $disp=array_slice($entries,$start,$increase);
    foreach ($disp as $d){echo "&#160;$d&#160;";}

    // If the end is smaller than the amount of items in increase, display the next
    // link, which sets start to start+increase
    if ($end < sizeof($entries)){
    echo "&#160;<a href=\"".$HTTP_SERVER_VARS['PHP_SELF']."?start=".($start+$increase)."\">next</a>";
    }
?>

If you are too lazy to type or copy + paste it, download this example as a zip click here.

Table of contents:

The issue with Previous and Next links
PHP to the rescue
The whole script

Back to top

Search:

 

Font:

Click to decrease fontsizeClick to increase fontsize

Text-colour:


Background:


sponsored by :

NWU

Help Onlinetools.org

Help onlinetools.org, donate via paypal

Partners

easyPHP

icons

Link to us

copy the code here:


Powered by EasyCMS