PDA

View Full Version : Multi images extra by nico



michael_s
08-29-2008, 10:02 AM
the query return zero records when the products_images table don't have the product_id record
I made a modification in the query to get info even if products_images is empty

replace original query
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");


by:
$product_info_query = tep_db_query("SELECT
p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity,
p.products_image,pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added,
p.products_date_available, p.manufacturers_id,
pi.products_image1, pi.products_image2, pi.products_image3, pi.products_image4, pi.products_image5,
pi.products_image6, pi.products_image7, pi.products_image8, pi.products_image9
FROM ".TABLE_PRODUCTS." as p
LEFT JOIN ".TABLE_PRODUCTS_DESCRIPTION." as pd ON (pd.products_id = p.products_id)
LEFT JOIN ".TABLE_PRODUCTS_IMAGES." as pi ON (pi.products_id = p.products_id)
WHERE p.products_status = '1'
AND p.products_id = '".(int)$HTTP_GET_VARS['products_id']."'
AND pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

More... (http://addons.oscommerce.com/info/4170)