April 10, 201214 yr I have a datafeed management script written in PHP / MySQL on X template (smarty, which was written in 2000 ) and basically trying to do some modifications without squat knowledge of PHP really. The script has 'popular products' function which from what i can see displays products by popularity from a column called 'prodPopularity' in the table affilist_products1, basically i want to replicate this but sort the products by 'rating' but this column is in another table called affilist_comments! this is the popular products, can anyone tell me what needs changing to accomplish this? Thanks in advance <?php /* if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) { echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>"; exit; } // get listing options $getListOptions = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'prodListings'"); $listOptions = mysql_fetch_assoc($getListOptions); $prodOptions = explode(":", $listOptions['value']); // popular products listing $getPopular = mysql_query("SELECT prodImageSmall, prodImageURL, prodName, merchantProdID, dbProdID, prodDB, prodPrice, prodCurrency, prodPopularity FROM affiliSt_products1 ORDER BY prodPopularity DESC LIMIT 0, 10"); $popularList = mysql_fetch_assoc($getPopular); $box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/popularprod.tpl"); do { // get titles $getTitles = mysql_query("SELECT value FROM affiliSt_config WHERE name = 'feedMemory".$popularList['prodDB']."'"); $allTitles = mysql_fetch_assoc($getTitles); $listTitles = explode("-:-", $allTitles['value']); // thumb image if ($popularList['prodImageSmall'] == NULL) { $thumbImage = $popularList['prodImageURL']; } else { $thumbImage = $popularList['prodImageSmall']; } $popResult = ucwords(strtolower($popularList['prodName'])); // use merchant product ids if ($navOpt[12] == 1) { $theprodID = $popularList['merchantProdID']; } else { $theprodID = $popularList['dbProdID']; } if ($navOpt[7] == 1) { // html perma $box_content->assign("LINKDATA",$installDir['value'].'product/'.$popularList['prodDB'].'/'.$theprodID.'/'.urltxt($popularList['prodName']).'.html'); $box_content->assign("IMAGELINK",$installDir['value'].'img/'.$popularList['prodDB'].'/'.$popularList['dbProdID'].'.jpg'); } else { // php link $box_content->assign("LINKDATA",$installDir['value'].'index.php?case=product&proddb='.$popularList['prodDB'].'&pid='.$theprodID); $box_content->assign("IMAGELINK",$thumbImage); } if ($prodOptions[6] == 1 && $popularList['prodPrice'] != '') { if ($prodOptions[12] == 1) { $theTitle = $listTitles[27]; } else { $theTitle = ''; } if ($popularList['prodPrice'] == 0.00) { $box_content->assign("PRICE",'<span class="popProdPrice">'.$theTitle.'N/A</span><br />'); } else { $box_content->assign("PRICE",'<span class="popProdPrice">'.$theTitle.$popularList['prodCurrency'].$popularList['prodPrice'].'</span><br />'); } } else { $box_content->assign("PRICE",''); } $box_content->assign("DATA",substr($popResult, 0, 30).''); $box_content->assign("POPIMAGE",$popularList['dbProdID']); $box_content->parse("popularprod.li"); } while ($popularList = mysql_fetch_assoc($getPopular)); $box_content->assign("DATA", "Popular Products"); $box_content->assign("SKIN",$configSkin['value']); $box_content->parse("popularprod"); $box_content = $box_content->text("popularprod"); ?> thanks!
April 20, 201214 yr if the affilist_products1 table has a foreign key to the affilist_comments table you can use an INNER JOIN to get the rating then ORDER BY rating ASC (or DESC).
Create an account or sign in to comment