Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:11:43+00:00 2026-06-08T17:11:43+00:00

I have a dynamic page that pulls the categories from the database. this page

  • 0

I have a dynamic page that pulls the categories from the database. this page is categories.php?CTGID=####, CTGID standing for the category number. Each product then has an ID assigned to it.

When they click on the product within the category it goes to a page Products.php?ID=###. What I want to create is when they are within the Product page there is a next and previous button.

What I would essentially need it to do is get the CTGID of the current product ID then the next button would be the ID of the next product withing that Category ID.

<?php
$db=mysql_connect ("localhost",[username],[password]) or die(mysql_error());
mysql_select_db("rentals");
$rentID = $_GET['ID'];
//Strip html
$strip_ID = strip_tags($rentID);
$html = htmlentities($strip_ID, ENT_QUOTES);
$escape = addslashes($html);
$table="online_rental_db";

$sql = "SELECT * FROM $table WHERE ID=$escape";
$query = mysql_query($sql) or die(mysql_error());
$rentals = mysql_fetch_assoc($query);
$description = ucwords(strtolower($rentals['Description']));
$image = $rentals['Image'];
$download = $rentals['PDF'];
$ID = $rentals['ID'];
$CTGID = $rentals['CTGID'];
$category = $rentals['Category'];
$video = $rentals['Video'];
$bytes = filesize("rentals/".$download);
$model = $rentals['Model'];
$made = ucwords(strtolower($rentals['Manufacturer']));
$productnum = $rentals['Productnum'];

then on the page I just echo out what I need in what area. I have read some articles on the next and previous buttons, but decided I might need some extra advice!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:11:45+00:00Added an answer on June 8, 2026 at 5:11 pm

    Not sure what you’ve tried, but in the past I’ve implemented getting next/previous values from the DB with the following queries:

    $curId  = 42;  // current product id
    $curCat = 1;   // current category
    
    $sqlPrev = 'SELECT `id` FROM `table`
                WHERE `id` < '$curId' AND `catId` = '$curCat'
                ORDER BY `id` DESC LIMIT 1;
    
    $sqlNext = 'SELECT `id` FROM `table`
                WHERE `id` > '$curId' AND `catId` = '$curCat'
                ORDER BY `id` ASC LIMIT 1;
    
    // execute each query
    

    If you get no result back from one of the two queries, it means you are on the first or last item in that category so there is no prev/next button in that case.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have single php dynamic page that load image each time app user is
I have a dynamic page that gets a certain number of results for rooms
I have a dynamic page that looks like the following: www.sitedomain.com/page.php?id=30&name=about_our_company I want to
I have a small problem. So I have this page that loads dynamic content
I have an application which pulls XAML page paths from a database. I can
I have a page that includes a dynamic js-script depending on the page I'm
I have a web page that displays dynamic data which changes every 2 seconds.
i have a dynamic php web page localhost/ctd/index.php All working good except if i
I have a dynamic drop down box which calls another PHP page. I've got
I have dynamic page. There are multiple checkboxes & I am using this script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.