Guest Posted March 17, 2003 Share Posted March 17, 2003 I'm trying to modify the file new_products.php to pull more info from the database. I've sort of succeded but would like someone with a bit more knowledge of the database functions to look over the following code. I'm trying to pull the following : $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_model, p.products_quantity, p.products_weight, p.manufacturers_id, p.products_price, p.products_date_added, pd.products_name, m.manufacturers_image, 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, cd.categories_name, cd.categories_id, c.parent_id Using the following: from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on p2c.categories_id = cd.categories_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . $languages_id . "' and cd.language_id = '" . $languages_id . "' order by rand() DESC limit " . MAX_DISPLAY_NEW_PRODUCTS); and then: } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_model, p.products_quantity, p.products_weight, pd.products_name, p.manufacturers_id, p.products_price, p.products_date_added, m.manufacturers_image, 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, cd.categories_name, cd.categories_id Using: from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on p2c.categories_id = cd.categories_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c 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.parent_id = '" . $new_products_category_id . "' and p.products_status = '1'and pd.language_id = '" . $languages_id . "' and cd.language_id = '" . $languages_id . "' order by rand() DESC limit " . MAX_DISPLAY_NEW_PRODUCTS); You can see what I'm trying to achieve at www.webdesign.dcpc.co.uk Its the new/featured product boxes all based around the main default/index.php file. Next where the ($category_depth == 'products' I've had to use another new_products.php file called new_products1.php to make the same query but at the products depth as I can't figure out how to add the query to the above code. This query is as follows: $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_model, p.products_quantity, p.products_weight, pd.products_name, p.manufacturers_id, m.manufacturers_image, p.products_price, p.products_date_added, 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,cd.categories_name,cd.categories_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on p2c.categories_id = cd.categories_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c 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 cd.categories_name = '" . $category[categories_name] . "' and p.products_status = '1'and pd.language_id = '" . $languages_id . "' and cd.language_id = '" . $languages_id . "' order by rand() DESC limit 2" ); If anyone can help out it would be much appreciated. Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.