Site Navigation Code

  Home arrow Site Navigation Code arrow Navigate through records
SITE NAVIGATION CODE

Navigate through records
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This is some sample code to be able to navigate through records in a record set. I use it as an include, you can use it however you wish!

    By : bryan

    <?php

    // Variables for navigating between previous and next record id

    $previd = $id-1;
    $nextid = $id+1;

    // Your database connection code

    $dbcnx = mysql_connect('localhost:', 'mysql','yourpass')
    or die("Error Occurred");

    mysql_selectdb("YourDB");

    $query = "SELECT * FROM yourtable WHERE id='$id'";
    $result = mysql_query($query, $dbcnx);
    $row = mysql_fetch_array($result);

    // Checking and displaying data

    If (($id > 0) && ($id <= sizeof($row))) {

    echo $row['your array'];
    echo "<a href=\"page.php?id=$previd\">Previous</a>
    <a href=\"page.php?id=$nextid\">Next</a>";

    } else {

    if ($id < 1) {
    echo "Beginning of Record Set"." ";
    echo "<a href=\"page.php?id=$nextid\">Next</a>";
    } else {
    echo "End of Record Set"." ";
    echo "<a href=\"page.php?id=$previd\">Previous</a>";
    }
    }
    ?>
    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.

    More Site Navigation Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    SITE NAVIGATION CODE ARTICLES

    - Simple Menu System
    - Simply image viewer script
    - Simple File Lister
    - Dynamic Error Pages
    - BSoftEditor
    - Yahoo Status
    - Page numbers
    - PHP Search Navigator 1.0
    - Simple Page Navigation
    - An easy page browser ( prev 6 7 8 9 10 next )
    - AutoIndex PHP Script (Directory Indexer)
    - Bs_HtmlNavigation (Navigation and Sitemap cl...
    - Another Paging with Stage
    - Website Navigation via PHP
    - MySQL Paging Class

    Developer Shed Affiliates

     



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