Forum Moderators: coopster

Message Too Old, No Replies

Top views last week

How to make?

         

rowtc2

1:00 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



I have around 2.000 articles and i have a row with the number of views.I have dinamic total number of views for each article.

I want to make a top with the number of views for Last Week,not just total.

Any idea how to make this?

d40sithui

4:20 pm on Sep 10, 2009 (gmt 0)

10+ Year Member



If you want a record for a certain time frame such as last week, you will need to save the views day by day. A table consisting of article_id, day, counter for each 365 days. A standard views table only captures the total.

rocknbil

6:12 pm on Sep 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have view timestamps for the article views? If not, you're out of luck.

select count(*) from pageviews where article_id='$some_id' and date >= date_sub(curdate(), interval 7 day) and date < curdate();

Note this only gets the last 7 days and may not be "last week." To do that, you'll have to get and store the actual dates of the first and last days of "last week," store those dates in variables, and use them in the >= and <. It's a little complex but once you have it, it's done.