PHP MYSQL Next and Previous Product Buttons
===

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 am wanting to create is when they are withing 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","Krunch","Krunch10") 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!
