View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Showing Multiple Categories At Once

Thread began 10/29/2009 5:34 pm by larsentim278054 | Last modified 11/13/2009 5:24 pm by larsentim278054 | 3461 views | 30 replies


The problem with that is, as you say, it's quite complex and I don't know SQL as well as I should. I have no idea how to "modify" it to show only certain categories - my goal is to show a page that includes only categories that I choose. I was able to do this - but as you saw - it shows every product instead of just the first one.

Here's the sql from the regular (default) product_results page:

$maxRows_WADAProducts = 9;
$pageNum_WADAProducts = 0;
if (isset($_GET['pageNum_WADAProducts'])) {
$pageNum_WADAProducts = $_GET['pageNum_WADAProducts'];
$startRow_WADAProducts = $pageNum_WADAProducts * $maxRows_WADAProducts;

mysql_select_db($database_localhost, $localhost);
$query_WADAProducts = "SELECT *, (ProductStock - (SELECT Coalesce(Sum(DetailQuantity),0) FROM orderdetails INNER JOIN orders ON OrderID = DetailOrderID WHERE DetailProductID = ProductID AND OrderDate > ProductUpdateDate)) AS NumLeft, (SELECT MAX(ProductPrice) FROM products as prod2 INNER JOIN productoptions ON productoptions.ProductID = prod2.ProductID WHERE productoptions.GroupingID = products.ProductID AND prod2.ProductLive <> 0) AS TopPrice, (SELECT MIN(ProductPrice) FROM products as prod2 INNER JOIN productoptions ON productoptions.ProductID = prod2.ProductID WHERE productoptions.GroupingID = products.ProductID AND prod2.ProductLive <> 0) AS BottomPrice FROM products LEFT OUTER JOIN productcategories ON ProductCategoryID = CategoryID WHERE ProductLive <> 0 AND COALESCE((SELECT GroupingID FROM productoptions WHERE productoptions.ProductID = products.ProductID LIMIT 1), ProductID) = ProductID";
$query_WADAProducts.= preg_replace("/ AND /", " HAVING ", $WADbSearch2->whereClause, 1);
$query_limit_WADAProducts = sprintf("%s LIMIT %d, %d", $query_WADAProducts, $startRow_WADAProducts, $maxRows_WADAProducts);
$WADAProducts = mysql_query($query_limit_WADAProducts, $localhost) or die(mysql_error());
$row_WADAProducts = mysql_fetch_assoc($WADAProducts);

if (isset($_GET['totalRows_WADAProducts'])) {
$totalRows_WADAProducts = $_GET['totalRows_WADAProducts'];
} else {
$all_WADAProducts = mysql_query($query_WADAProducts);
$totalRows_WADAProducts = mysql_num_rows($all_WADAProducts);
$totalPages_WADAProducts = ceil($totalRows_WADAProducts/$maxRows_WADAProducts)-1;

And here's the SQL from the new page I made that only shows categories 1,2 and 3:

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
return $theValue;

$maxRows_carseats = 6;
$pageNum_carseats = 0;
if (isset($_GET['pageNum_carseats'])) {
$pageNum_carseats = $_GET['pageNum_carseats'];
$startRow_carseats = $pageNum_carseats * $maxRows_carseats;

mysql_select_db($database_localhost, $localhost);
$query_carseats = "SELECT * FROM products WHERE ProductCategoryID = 1 OR ProductCategoryID = 2 OR ProductCategoryID = 3";
$query_limit_carseats = sprintf("%s LIMIT %d, %d", $query_carseats, $startRow_carseats, $maxRows_carseats);
$carseats = mysql_query($query_limit_carseats, $localhost) or die(mysql_error());
$row_carseats = mysql_fetch_assoc($carseats);

if (isset($_GET['totalRows_carseats'])) {
$totalRows_carseats = $_GET['totalRows_carseats'];
} else {
$all_carseats = mysql_query($query_carseats);
$totalRows_carseats = mysql_num_rows($all_carseats);
$totalPages_carseats = ceil($totalRows_carseats/$maxRows_carseats)-1;


Much smaller. Please let me know how to modify either one. Whichever one is easiest.

I really appreciate your help - I know this isn't the normal scope of things, but I gather (and have heard from others) that this is a wanted option (to show multiple categories on a results page).


Edit: I realize that first code I put up there is very hard to read because one line is extremely long (and unfortunately, that one line is the one that tells it to limit the one product) - but I don't know how to make it more readable. To read it, you need to scroll all the way to the right. Otherwise you won't see the most important part.

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





Ease of use


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...