mouldy_punk
08-11-2004, 07:28 AM
I've made a counter for my site (scratched the idea of detecting resolution) and it detects the viewers IP OS and browser. All works well and I can count how many rows in the mysql table and thats how many unique hits I've had....marvelous. Any way. I've added a extra field and its a "last_visit" field. It updates the date to when the visitor last visited the site. How do I make a page that will say what the date when the site was the busiest?
One more thing also. On the part that detects the browser. It reckons firefox is netscape. Is there a way around that or is it just because its based on netscape?
wimvds
08-11-2004, 07:42 AM
For the counter question, just do the following (if you're using MySQL, syntax will vary slightly if using other RDBMS) :
select last_visit, count(*) as total from unique_visitors_table group by last_visit order by total desc limit 1
This will return the row you need (and the total # of hits you received that day). Make sure to add an index on the last_visit date though (if you haven't done it already).
As for the browser detection, it is possible to check for Firefox. Just look at the user agent, if it contains Firefox then it's Firefox (or another browser pretending to be Firefox :p). Everything depends on how you check it, your browser detection logic might be wrong (ie. detect things in the wrong order).
Dan Grossman
08-12-2004, 04:10 AM
If you're only storing last_visit, this won't give you your busiest day since you know nothing about days before each visitor's last visit. You'd have to record the timestamps of every visit, or store your busiest day elsewhere and every day check if the current day's stats are greater and update it.
mouldy_punk
08-12-2004, 08:54 AM
oh yeah. I didn't realise that. Thanks for pointing it out. That is probably why I couldn't figure out how to do it :p I'll do the more detailed stats in a different table because this table will also be part of a member system I'm making.