Database Articles

  Home arrow Database Articles arrow Page 3 - 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 - Starting Off with $start


    (Page 3 of 5 )

    Ok, so now we now what we are going to use to obtain the proper rows from the database. The question is, how do we know what to limit it by? Simple, we will pass a variable called $start from page to page. Now, let's start putting a little PHP code down.

    <?php
    $query 
    "SELECT * FROM table LIMIT " $start ", 10";
    ?>

    Ok, that's what our query is going to look like. Simple as that. This will select 10 rows from the table starting at whatever position $start is equal to.

    When you are handing out your url, you don't want to give someone this: http://myserver.com/?start=0. That's just plain ugly. So, we need to assign an initial value to $start if it doesn't have one.

    <?php
    if(!isset($start)) $start 0;
    ?>

    Easy! Now, when someone hits our page, $start will be set to 0 (zero).

    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 7 - Follow our Sitemap