Reputation: 621
I want to create simple kind of stats for a page. How can I store the number of hits of last 7 days in the database? I just need an idea about how to store only previous 7 days data in the database. Something like:
and so on?
Do I need to make like 7 columns to store each days hits number or I can manage with one column?
Upvotes: 1
Views: 342
Reputation: 4733
I think it would be easier to just store every visit to your database and select the COUNT() of the last 7 days.
Or you could make an extra table that has 1 row for every day and just select the last 7 days with INTERVAL() function.
Upvotes: 1
Reputation: 34408
I'd suggest you add another table
and store one row per page per day. You can then delete all rows from this table where date is > 7 days old as a daily job.
Upvotes: 1