Leeb2 Posted February 11, 2007 Share Posted February 11, 2007 Can this query in new_products.php be rewritten so that only products from certain categories would be shown on the New Products module on the index page? $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); How would you rewrite this to show products with only say categories_id 1 and 2? Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted February 12, 2007 Share Posted February 12, 2007 $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES ." ptc where products_status = '1' and ptc.products_id = p.products_id and ptc.categories_id in (1, 2) order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); Not tested, but I think this will work KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Leeb2 Posted February 12, 2007 Author Share Posted February 12, 2007 $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES ." ptc where products_status = '1' and ptc.products_id = p.products_id and ptc.categories_id in (1, 2) order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); Not tested, but I think this will work Thanks bruyndoncx, that worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.