Need some Help Please check Query
Posted by:
raj uni
Date: March 18, 2011 09:34PM
HI my site shows a product page in that we show detailed product desp.
On the right we show a nox showing products " peopel who viewed this also view"
The criteria for the above matches the main product that is if main product is "From Macy" then the right will show most viewed products viewed by people of Macy
Want to add a condition where in case for some reason this box is empty ( new merchant who has only one product} then the box should show most viewed products of the category instead of merchant.. code for box is below..
-------------------------------------------------
$merhcnat_qry=" and TP.merchant_name ='$merchant_n' ";
}
$sql_res_image="select TP.product_name,TP.id,TP.buyurl,TP.url,TP.keywords,TP.brief_description,TP.currency,TP.detail_description,TP.views ,TP.vendor_id,TP.price,TC.category_name,TS.subcat_name,TP.promotional_id , TP.product_image,TP.discount,TP.super_deal ,TP.product_type,TP.currency_name,TP.network from ".TABLE_PRODUCT_MASTER." as TP, ".TABLE_CATEGORY." as TC, ".TABLE_SUBCATEGORY." as TS, ".TABLE_POPULAR_PRODUCT." as PP where TP.id=PP.product_id and TP.status='".ACTIVE."' and TP.category_id=TC.id and TP.subcategory_id=TS.id and TP.id <> '$product_id' $merhcnat_qry order by PP.display_count desc limit 0 , 3";
-------------------------------------------------
Please suggest
Rajiv