From 3342c55772f9435dac74e3e2c0f9b3bbd63f1210 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sat, 25 Jun 2005 03:44:39 +0000 Subject: [PATCH] Keep track of the appIds we've already output to the top X list. If we need to fill the list in with applications that haven't received any votes make sure we exclude the applications we've already output. --- include/util.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/util.php b/include/util.php index b4adff3..b8551a3 100644 --- a/include/util.php +++ b/include/util.php @@ -256,6 +256,10 @@ function lookupVendorName($vendorId) /* Output the rows for the Top-X tables on the main page */ function outputTopXRowAppsFromRating($rating, $num_apps) { + /* list of appIds we've already output, so we don't output */ + /* them again when filling in any empty spots in the list */ + $appIdArray = array(); + $sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c FROM appVotes, appVersion WHERE appVersion.maintainer_rating = '$rating' @@ -267,6 +271,8 @@ function outputTopXRowAppsFromRating($rating, $num_apps) $num_apps-=mysql_num_rows($hResult); /* take away the rows we are outputting here */ while($oRow = mysql_fetch_object($hResult)) { + array_push($appIdArray, $oRow->appId); /* keep track of the apps we've already output */ + $oApp = new Application($oRow->appId); // image $img = get_screenshot_img($oRow->appId); @@ -284,8 +290,15 @@ function outputTopXRowAppsFromRating($rating, $num_apps) WHERE appVersion.maintainer_rating = '$rating' AND appVersion.versionId = appData.versionId AND appData.type = 'image' - AND appData.queued = 'false' - LIMIT $num_apps"; + AND appData.queued = 'false'"; + + /* make sure we exclude any apps we've already output */ + foreach($appIdArray as $key=>$value) + $sQuery.="AND appVersion.appId != '".$value."' "; + + $sQuery.=" LIMIT $num_apps"; + + /* get the list that will fill the empty spots */ $hResult = query_appdb($sQuery); while($oRow = mysql_fetch_object($hResult)) {