linux-tech
10-13-2006, 05:46 PM
I've been working on things a bit now, and can't seem to find how to do this one so that it works here. Maybe someone can give a bit of advice.
When individuals go to my webpage, a counter is called which grabs their stats (os, browser, referrer, etc), and throws that into an SQL table.
What I'm trying to do is pull the top 5 of each stat out of the database. Browser, OS, viewed from this table. I've tried the following:
$bquery=$db->sql_query("SELECT browser, COUNT(browser) FROM statistics GROUP BY browser");
while ($row=$db->sql_fetch_array($bquery))
{
$bcount=$row[COUNT(browser)];
$browser=$row[browser];
}
However, that returns one result, and typically the lowest result, not anything in the top 5.
Is there a better way to do this somehow? Something that I'm just not catching?
When individuals go to my webpage, a counter is called which grabs their stats (os, browser, referrer, etc), and throws that into an SQL table.
What I'm trying to do is pull the top 5 of each stat out of the database. Browser, OS, viewed from this table. I've tried the following:
$bquery=$db->sql_query("SELECT browser, COUNT(browser) FROM statistics GROUP BY browser");
while ($row=$db->sql_fetch_array($bquery))
{
$bcount=$row[COUNT(browser)];
$browser=$row[browser];
}
However, that returns one result, and typically the lowest result, not anything in the top 5.
Is there a better way to do this somehow? Something that I'm just not catching?
