Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count "top 10 articles" on a web site 1

Status
Not open for further replies.

aliashippysmom

Programmer
Jul 29, 2004
43
0
0
US
Hi! I'm not sure how to do this. I have a web site and I would like to be able to display "top 10 new items" or something like that. I can now count how many times users click on certain links, but this is just a "one-up" number. I can display the most popular item in a certain time period based on when the item was uploaded to the site. I can display counts for all articles posted in a date range. Is there a simple strategy to be able to display the Most Popular items? The only thing I can come up with is some strategy to count number of hits on each article per day and then do...what?

Keep in mind that the longer the article is on the site, the more hits it will have over time, maybe. I hope this makes sense.

Has anyone ever done this? I see it on news sites all the time. THANKS!

 
I think you see the problem with just collecting total hits.

There are 2 solutions I've seen.

#1 - log every page load per article with the Date (and IP, or Session ID in case you want Unique hits) then query against it for hits within any date period. This solution gives you the most flexibility but takes the most DB space and can get slow over time.

#2 - log hits throughout the day and then compile them at night into a total for that day. This saves space over the first solution but you have to decide from the start if you want to save Unique hits, or just page loads. Also doesn't allow any kind of Intra-day statistics for "What's Hot" type functionality.

One of the factors that you will want to take into account is the number of hits each article is likely to get in a day. Also, if there would ever be a time when you would be able to throw out the old data in order to keep your tables small and fast.

I hope that helps

Travis Hawkins
jobs.bestcodingpractices.com
 
Thanks so much. And you're right collecting just the running total doesn't tell you quite enough. I like your option 2 and this seems to be something I could do in the future when I have more time. For the time being, until I have time to implement something more rigorous, I've just decided to view articles from this year only (of course). Then I am making a calculation for each article: I take the raw number of hits and divide this number by today's date - date article posted:

raw hits/(dayofyear(now()))-(dayofyear(posteddate))

The larger this number, the more popular. Not sure this makes complete sense, but it seems to jibe with what I'm seeing. Articles that are on the site longer, even though they may have a large number of hits, will evenually become unpopular. An article posted recently, though, with a moderate number of hits, could be considered popular.

Any other thoughts would be appreciated and thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top