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!
Get the user agent each time the page loads (automagically stored in the $HTTP_USER_AGENT variable). After getting the user agent, write it a DB, along with a time/date stamp.
Now, for your counter, just select all hits in the DB on today's date.
you could open a file using the write option and change a number everytime the script is accessed and use an auot-date feature before your return results to show the date. You could also add a line in your script that gets the date to determine if its a new day and the script should reset.
you could open a file using the write option and change a number everytime
The only problem with that is you have to watch out for the script being called more than once at the same time. You can use file locking, but that can also cause problems. Best solution is to put the info in a database.
It might be an idea to have an automatic delete after a few days other wise your database will get very full if you have lots of visitors/pageviews
With only one record per day, it would take hundreds of years before it would fill up.
Instead of deleting the historical data, you could generate really interesting graphs with it instead:
last week visitor graphs
a graph comparing last week to the first week in may
yesterday compared to the average stats of monday
last 30 days graph
etc...