1 Reply Latest reply on Mar 18, 2010 10:39 AM by icode4u

    next button on detail page

    lazlo

      Hi,

       

      I have:

       

      PAGE 1

      containing a recordset, showing a list down the page by way of a repeat region. Each entry has a link to PAGE2?detail=the row ID

       

      PAGE 2

      containg the detail record set (filter by ID = URL parameter 'detail'

       

      Can someone advise how to place a link "Next Article", on the detail page (PAGE 2) to PAGE 2 to show the next record in the list from PAGE 1

       

      I would like to create this funtionality so the user doesn't have to keep going back to the main list to choose the next record, they could for instance select the 4th record on the list, go to the details page and from there either go backwards or forwards to the previous or next record.

       

      any help appreciated.

        • 1. Re: next button on detail page
          icode4u

          Hello Lazlo

          What you will need to do is execute a sql statement to retrive the next record ID in the database. Now since you would not know exactly what record the user is going to click on to view the detials of that record you need two variables

           

          1. The ID of the record that use is viewing the details of

          2. The next record ID in the database.

           

          To retirve the next record ID you need to put the current ID into a variable. The example below assumes your are passing the record id in the url to the details page

           

          $currentID=$_GET['ID'];

           

           

          Then execute the follwing mySQL statement on the details page. Replace the field names and table name with the your table names and fields.

           

          $sql="SELECT MIN(ID) AS nextID FROM tablename WHERE ID > "$currentID'";

          $result=mysql_query($sql)or die(mysql_error() . " - $sql");

          $row=mysql_fetch_assoc($result);

          $nextID=$row['nextID'];

           

          Now all you need to do is to create a link to the next record as follows;

           

          http://www.yourdetailspage.php?ID=<?php echo $nextID; ?>
          

           

          Hope this helps

          Stan Forrest