Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,473
There are 2101 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Track Page Views & Create "Top Pages This Week"

Thread title: Track Page Views & Create "Top Pages This Week"
Reply    
    Thread tools Search this thread Display Modes  
01-18-2010, 11:19 PM
#1
JasonGDX is offline JasonGDX
JasonGDX's Avatar
Status: Junior Member
Join date: Nov 2006
Location: Pennsylvania, USA
Expertise: Design, HTML, CSS, PHP, MySQL
Software: Photoshop, Coda
 
Posts: 95
iTrader: 4 / 100%
 

JasonGDX is on a distinguished road

  Old  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.

Reply With Quote
01-23-2010, 02:09 AM
#2
mikeroq is offline mikeroq
mikeroq's Avatar
Status: Member
Join date: Feb 2006
Location: Ponca City, OK
Expertise: xHTML/CSS/PHP/Computer Tech
Software: Photoshop, Notepad++, Winamp
 
Posts: 332
iTrader: 5 / 100%
 

mikeroq is an unknown quantity at this point

Send a message via AIM to mikeroq Send a message via MSN to mikeroq Send a message via Yahoo to mikeroq

  Old

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.

Reply With Quote
02-09-2010, 05:13 PM
#3
Cyrus709 is offline Cyrus709
Cyrus709's Avatar
Status: I'm new around here
Join date: Feb 2010
Location: United States
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

Cyrus709 is on a distinguished road

  Old

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.

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed