Organizeing results from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Organizeing results from database

Post by josh »

I have a stat system I'm writeing for my website... how would i go about takeing what i have so far (a table filled with my entire log: ip, refferer, etc...) and putting it into like a stats page (xx% of people use internet explorer, XX% of ppl referred from http://www.somesite.com) keep in mind i already have all the stuff in the database and can retreive it... just need help organizeing it.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You just need to decide what you want to show and then create queries to retreive that data.

Number of unique IP's : SELECT count(DISTINCT ip) FROM stats

Total number of hits: SELECT count(*) FROM stats

Number of hits in last hour: SELECT count(*) FROM stats WHERE time > time()-3600

ect.

Then just print the result out in nice tables or however you wish to show it.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Thanks, this helps alot to get me started... I coded almost everything except I am stuck on one thing:
How would I check what the most popular item is, for instance:

all my pages are the same page (index.php?page=XXXXXXX)
like that, everytime the page loads it stores the value of $page into the database as column querry... how would i show a list of the top 10 querries?
Post Reply