Guest Posted December 8, 2002 Posted December 8, 2002 I'm working on revising the printable catalog. I am attempting to have all of the products listed in the same order as the category menu...i.e. top category->subcategory->product and then grouped by their respective categories. Example: Category:Swings Subcategory:Single Product: 6", 9", 12", 18", 24" Category:Swings Subcategory:Double Product: 6", 9", 12", 18", 24" Category: Toys Subcategory: Hanging Toys Sub-subcategory: Smal Birds Product: Zapper, Badda-Bing, What I have gotten so far can be seen @ http://www.bird-e-toys.com/osc/catalog/cat...g_printable.php Here's the query I am using: <?php if ($HTTP_GET_VARS['page'] >1) $rows = $HTTP_GET_VARS['page'] * 20 - 20; $products_query_raw = "SELECT p.products_id, p.products_image, pd.products_description, p.products_model, p.products_quantity, pd.products_name, p.manufacturers_id, p.products_price, c.parent_id, cd.categories_name, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id WHERE p.products_status = '1' AND p.products_id = p2c.products_id AND pd.products_id = p2c.products_id AND p2c.categories_id=c.categories_id AND c.categories_id=cd.categories_id AND pd.language_id = 1 ORDER BY c.parent_id AND cd.categories_name AND pd.products_id"; $products_query = tep_db_query($products_query_raw); while($products = tep_db_fetch_array($products_query)) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } ?> I know I'm pretty close but, I can't seem to get the ORDER BY to work quite right. I think this will be a good contribution if we can get this figured out...help???
Recommended Posts
Archived
This topic is now archived and is closed to further replies.