I need to show the top five tutorials on my site.
Everytime a tutorial is viewed an entry in my STATS table is added.
The entry includes an autoindex called statid, and an index called TUTORIALID is also added. The last thing thats added is the tutorial name in a field called NAME
I have the following code that successfully prints all the number of views, but I need it to order the views and display the last five in descending order displaying the name instead of the count.
<?
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT name, COUNT(*) as numArticles FROM stats GROUP BY tutorialid ORDER BY name ASC";
$results=mysql_query($query);
mysql_close();
$i=0;
while ($row = mysql_fetch_array($results)) {
echo "
$row[numArticles] ";
++$i;
}
?>
Any help would be appreciated, thanks!