Database Articles

  Home arrow Database Articles arrow Page 4 - PHP - Previous and Next Links
DATABASE ARTICLES

PHP - Previous and Next Links
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2002-02-04

    Table of Contents:
  • PHP - Previous and Next Links
  • The LIMIT Clause
  • Starting Off with $start
  • Building the Previous and Next Links
  • Putting It All Together

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    PHP - Previous and Next Links - Building the Previous and Next Links


    (Page 4 of 5 )

    Ok, down to the part you've been looking forward to. Let's actually make those Previous and Next links.

    First of all, let's think about it for a second. Say you have a variable named $start (we do), so you know the first row someone is looking at and you know how many rows total there are in your result (we will) then you can easily determine if Previous or Next links are needed.

    If $start is higher than 0 (zero), then we need to display a Previous Link so that people can see records before $start. If the number of rows in your result is greater than $start plus the number of rows we are displaying (in our examples 10) we need to display a Next link. This is the basis of our code logic. If you got this, writing the code is easy.

    <?php
    if($start &gt0
       echo 
    "&lt;a href=\"" $PHP_SELF "?start=" . ($start 10) . 
            
    "\"&gt;Previous&lt;/a&gt;&lt;BR&gt;\n";
    if(
    $numrows > ($start 10)) 
       echo 
    "&lt;a href=\"" $PHP_SELF "?start=" . ($start 10) . 
            
    "\"&gt;Next&lt;/a&gt;&lt;BR&gt;\n";
    ?>

    More Database Articles Articles
    More By Matt Wade

    blog comments powered by Disqus

    DATABASE ARTICLES ARTICLES

    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual
    - Using Oracle SQL Developer with SQL Statemen...
    - Fixing Errors with Oracle SQL Developer


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