"; // CATALOG IN MAIN PAGE print "

TOP CATEGORIES

"; $catres=@mysql_query("select * from site_categories where catlist=1 order by type,sortkey",$c); print "
"; while ($catrow=@mysql_fetch_assoc($catres)){ if (@in_array($catrow['categoryid'],$showcats)||empty($showcats)){ $catname=explode("--",$catrow['catname']); if ($count==5){$count=0;print "";} print ""; $count++;$count2++; if ($count==5){ print ""; print ""; } else { print ""; } } } if ($count==1){ print ""; } elseif ($count==2){ print ""; } elseif ($count==3){ print ""; } elseif ($count==4){ print ""; } print "
"; unset ($keyimg); if (strlen($catrow['catimg'])){ $catimginfo=@mysql_fetch_assoc(@mysql_query("select keyimg from site_products where sku='".$catrow['catimg']."'",$c)); $keyimg=$catimginfo['keyimg']; } else { $q="SELECT c.categoryid FROM site_categories c JOIN site_prod_cat_cross pcc ON (pcc.categoryid=c.categoryid) WHERE c.subto='".$catrow['categoryid']."' ORDER BY RAND() LIMIT 1"; $subcheck=@mysql_fetch_assoc(@mysql_query($q,$c)); // ARE THERE SUBCATEGORIES? // IF YES, THEN PICK A SUB AT RANDOM, THEN FROM THAT SUB PICK A PRODUCT PIC if ($subcheck['categoryid']>0){ $randimg=@mysql_fetch_assoc(@mysql_query("select p.keyimg from site_categories c JOIN site_prod_cat_cross pcc ON (pcc.categoryid=c.categoryid) JOIN site_products p ON (p.sku=pcc.sku) where c.categoryid='".$subcheck['categoryid']."' and p.status='Live' ORDER BY RAND() LIMIT 1",$c)); } else { // IF NO, THEN PICK A PRODUCT PIC AT RANDOM $randimg=@mysql_fetch_assoc(@mysql_query("select p.keyimg from site_categories c JOIN site_prod_cat_cross pcc ON (pcc.categoryid=c.categoryid) JOIN site_products p ON (p.sku=pcc.sku) where c.categoryid='".$catrow['categoryid']."' and p.status='Live' ORDER BY RAND() LIMIT 1",$c)); } $keyimg=$randimg['keyimg']; } if (!empty($keyimg)){ list($cwidth,$cheight)=getimagesize(PROD_IMAGES.$keyimg."_SM.jpg"); // determine which dimension will survive based on ratios: if ($cwidth/$cheight>=1){ // width rules $new_width=round($cwidth*150/$cwidth,0); $new_height=round($cheight*150/$cwidth,0); } else { // height rules $new_width=round($cwidth*150/$cheight,0); $new_height=round($cheight*150/$cheight,0); } print "".$catrow["; } else { print "".$catname[1].""; } print "
"; print "
"; echo pullPageContent("home"); print "
"; include (INCLUDES_DIR."comp_footer2.inc.php"); ?>