close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Display Products within a category

Thread began 1/30/2015 6:09 am by Kumel | Last modified 2/06/2015 4:32 pm by Kumel | 1450 views | 16 replies

Jason ByrnesWebAssist

there is no page attached, but using ftp from a previous incident i accessed the files on your server.

for one the code for the products recordset is duplicated:

$colname1_products = "-1";
if (isset($row_categories['CategoryID'])) {
$colname1_products = $row_categories['CategoryID'];
}
mysql_select_db($database_con1, $con1);
$query_products = sprintf("SELECT productcategories.*, products.* FROM productcategories INNER JOIN products ON productcategories.CategoryID = products.ProductCategoryID WHERE productcategories.CategoryID = %s", GetSQLValueString($colname1_products, "int"));
$products = mysql_query($query_products, $con1) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);$colname1_products = "-1";
if (isset($row_categories['CategoryID'])) {
$colname1_products = $row_categories['CategoryID'];
}
mysql_select_db($database_con1, $con1);
$query_products = sprintf("SELECT products.*, productcategories.* FROM products INNER JOIN productcategories ON products.ProductCategoryID = productcategories.CategoryID WHERE products.ProductCategoryID = %s", GetSQLValueString($colname1_products, "int"));
$products = mysql_query($query_products, $con1) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);




i edited that code to remove the duplication and use the correct variable and column in the recordset:

$colname1_products = "-1";
if (isset($_GET['CategoryLink'])) {
$colname1_products = $_GET['CategoryLink'];
}
mysql_select_db($database_con1, $con1);
$query_products = sprintf("SELECT productcategories.*, products.* FROM productcategories INNER JOIN products ON productcategories.CategoryID = products.ProductCategoryID WHERE productcategories.CategoryLink = %s", GetSQLValueString($colname1_products, "text"));
$products = mysql_query($query_products, $con1) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);$colname1_products = "-1";




to fix the problem.


the reason it is not working using the lookup recordset is code order. the categories recordset is after the products recordset. so when the products recordset is created, $row_categories['CategoryID'] does not have a value yet.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...