Copy link to clipboard
Copied
ok ive done this before but now it doesnt seem to work. i have a product list page that shows categories, these are not dynamic then these are linked to the category page, but whats happening is all products in all categories are being displayed and i dont know why. any ideas?
code is below
each link on the category page is the following
<a href="product-page-list.php?catID=<?php echo $row_rsProd['catID']; ?>"><img name="cats_r2_c1" src="images/cats/cats_r2_c1.gif" width="232" height="90" border="0" id="cats_r2_c1" alt="" /></a>
then the code for the product-page-list.php is as follows
$var1_rsProd = "-1";
if (isset($_GET['catID'])) {
$var1_rsProd = $_GET['catID'];
}
mysql_select_db($database_JB, $JB);
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID AND JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));
$query_limit_rsProd = sprintf("%s LIMIT %d, %d", $query_rsProd, $startRow_rsProd, $maxRows_rsProd);
$rsProd = mysql_query($query_limit_rsProd, $JB) or die(mysql_error());
$row_rsProd = mysql_fetch_assoc($rsProd);
if (isset($_GET['totalRows_rsProd'])) {
$totalRows_rsProd = $_GET['totalRows_rsProd'];
} else {
$all_rsProd = mysql_query($query_rsProd);
$totalRows_rsProd = mysql_num_rows($all_rsProd);
}
$totalPages_rsProd = ceil($totalRows_rsProd/$maxRows_rsProd)-1;
then the images from the selected category are displayed as images
<img src="images/uploads/thumbs/<?php echo $row_rsProd['prodImage']; ?>"/>
any advise would be great
thanks
found out what i done had an AND rather than an =
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID AND JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));
changed to
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID = JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));
Copy link to clipboard
Copied
You say that the categories are not dynamic, but the link includes the category ID from a recordset result:
<a href="product-page-list.php?catID=<?php echo $row_rsProd['catID']; ?>">
Does the rsProd recordset exist on that page, and is it inserting the catID number in the link?
The code for product-page-list.php (at least the part that you show) looks OK.
Copy link to clipboard
Copied
ok i seen my error on the category page, as the are not dynamic i can specify the category eg. <a href="product-page-list.php?catID=2">
but on the product-page-list.php is strange it is still showing all the images from all catgories but the header is changing to show the relevent catagory
the header on the product-page-list.php is <p class="subHeader">You are viewing <?php echo $row_rsProd['catName']; ?></p>
the image is <img src="images/uploads/thumbs/<?php echo $row_rsProd['prodImage']; ?>"/>
the the recordset code is
$var1_rsProd = "-1";
if (isset($_GET['catID'])) {
$var1_rsProd = $_GET['catID'];
}
mysql_select_db($database_JB, $JB);
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID AND JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));
$query_limit_rsProd = sprintf("%s LIMIT %d, %d", $query_rsProd, $startRow_rsProd, $maxRows_rsProd);
$rsProd = mysql_query($query_limit_rsProd, $JB) or die(mysql_error());
$row_rsProd = mysql_fetch_assoc($rsProd);
Copy link to clipboard
Copied
found out what i done had an AND rather than an =
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID AND JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));
changed to
$query_rsProd = sprintf("SELECT * FROM JB_cats, JB_products WHERE JB_cats.catID = JB_products.catID AND JB_cats.catID = %s", GetSQLValueString($var1_rsProd, "int"));