hey guys that wasn't what i was looking for. i have different product categories and when a user clicks on a category, i display a bunch of products in that category. when a user click on one of those items, i want to display <<previous | next>> navigation to navigate through each record in the same category.
I just don't understand how to carry over the array of items from the same category from the category page to the product individual page (each record page), and then use that array to go over to the previous/next product (record).
Any help would be really really appreciated. I'm just a beginner and this is one hard problem that's been bugging me for weeks.
Here's my code. There's something wrong because for any record, it has $previous = 0 and $next is the last recordID.
if (isset($_GET['productID']))
$productID= $_GET['productID'];
else
$productID = "";
if (isset($_GET['category']))
$category = $_GET['category'];
else
$category = "";
$query = " SELECT * FROM productTable";
$query .= " WHERE";
if(strlen($productID) > 0)
{
$query .= " AND productID = " . $productID;
}
if(strlen($category) > 0)
{
$query .= " AND category= '" . $category . "'";
}
$count = 0;
$resultfetch = mysql_query($query);
while($resultfetch_ar = mysql_fetch_assoc($resultfetch))
{
$count = $count +1;
{
$previous = $count - 2;
$nextone = $count;
if ($previous > -1)
{
$resultfetch = mysql_query($query." LIMIT $previous,1");
$resultfetch_ar = mysql_fetch_assoc($resultfetch);
$previousid = $resultfetch_ar['productID'];
}
else
{
$previousid = 0;
}
$resultfetch = mysql_query($query." LIMIT $nextone,1");
$resultfetch_ar = mysql_fetch_assoc($resultfetch);
if (!$resultfetch_ar)
{
$nextid = 0;
}
else
{
$nextid = $resultfetch_ar['productID'];
}
}
}