|
|
|
|
Thread title: Track Page Views & Create "Top Pages This Week" |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
01-18-2010, 11:19 PM
|
#1
|
Status: Junior Member
Join date: Nov 2006
Location: Pennsylvania, USA
Expertise: Design, HTML, CSS, PHP, MySQL
Software: Photoshop, Coda
Posts: 95
|
Track Page Views & Create "Top Pages This Week"
What I'm trying to accomplish is essentially a "Most Viewed Games" section for the video game site I'm developing. I want to be able to track game page views and compile a "real-time" chart of the 10 Most Viewed Games based on the number of views within, let's say, 7 days from the current date.
What would be the best way to store this information in a database?
I'd like to also be able to "go back in time" so to speak and be able to view previous views based on date ranges and other criteria.
Just not sure how I would structure this in the database or what is the best way to be able to do this.
|
|
01-23-2010, 02:09 AM
|
#2
|
Status: Member
Join date: Feb 2006
Location: Ponca City, OK
Expertise: xHTML/CSS/PHP/Computer Tech
Software: Photoshop, Notepad++, Winamp
Posts: 332
|
I'm sure there is a better way to do this, but this is how I could do it. Each time someone views a game, a row gets inserted into a 'stats' table, recording game viewed, time, ip, etc. Then to display this simply select from the table all the rows that fit the game and the date range. Your 7 days back would always go back 7 days, and you could create a page where you could view select dates or date ranges.
|
|
02-09-2010, 05:13 PM
|
#3
|
Status: I'm new around here
Join date: Feb 2010
Location: United States
Expertise:
Software:
Posts: 1
|
This is how i would do it, I would have a table that has columns IP, Views, Date, with the IP column unique (pretty much what mike said)
The php code would not count any views with the same IP, so that your views are not of people coming back to the same page, increasing the accuracy of the site. I would also make the Date column insertion not display the actual date but a number that represents a date, a row would say "1" representing day one, this way you could use mysql_num_rows to check a number less then X and greater then Y. This would be much simpler then using actual dates where you might have to convert them into seconds and then use them.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|