include("path.php");
include(BASE."include/"."incl.php");
require(BASE."include/"."category.php");
/* default to 25 apps, main categories */
$topNumber = 25;
$categoryId = "any"; /* default to all categories */
/* process the post variables to override the default settings */
if($HTTP_POST_VARS)
{
if(isset($_POST['topNumber'])) $topNumber = $_POST['topNumber'];
if(isset($_POST['categoryId'])) $categoryId = $_POST['categoryId'];
}
apidb_header("Vote Stats - Top $topNumber Applications");
/* display the selection for the top number of apps to view */
echo "
";
echo "
";
echo "
";
/***************************************************/
/* build a list of the apps in the chosen category */
if(strcasecmp($categoryId, "any") == 0)
{
/* leave out the appFamily.catId = '$categoryId' */
$voteQuery = "SELECT appVotes.appId, appName, count(userId) as count ".
"FROM appVotes, appFamily ".
"WHERE appVotes.appId = appFamily.appId ".
"GROUP BY appId ORDER BY count DESC LIMIT $topNumber";
} else
{
$voteQuery = "SELECT appVotes.appId, appName, count(userId) as count ".
"FROM appVotes, appFamily, appCategory ".
"WHERE appVotes.appId = appFamily.appId AND ".
"(appFamily.catId = '$categoryId' OR ".
"(appFamily.catId = appCategory.catId AND appCategory.catParent = '$categoryId')) ".
"GROUP BY appId ORDER BY count DESC LIMIT $topNumber";
}
$result = mysql_query($voteQuery);
if($result)
{
echo html_frame_start("", "90%", '', 0);
echo html_table_begin("width='100%' align=center");
echo "| Application Name | \n";
echo "Votes |
\n";
$c = 1;
while($row = mysql_fetch_object($result))
{
if ($c % 2 == 1) { $bgcolor = "color0"; } else { $bgcolor = "color1"; }
$link = "$row->appName";
echo "| $c. $link | $row->count |
\n";
$c++;
}
echo html_table_end();
echo html_frame_end();
/* Make sure we tell the user here are no apps, otherwise they might */
/* think that something went wrong with the server */
if($c == 1)
{
echo "No apps found in this category
";
}
echo "What does this screen mean?\n";
}
else
{
echo "Error: " . mysql_error();
}
apidb_footer();
?>