Jump to content

Most Viewed in 1 week time period


helpmeplease2

Recommended Posts

How can I do this?

 

I want to keep track of the most viewed games on my website (www.gameanyone.com)

 

I can guess that you add some $b=$a+1; and then insert the $b.. but that would only count views. How can I count the number of views in the last week or better the last 7 days?

Link to comment
https://forums.phpfreaks.com/topic/90231-most-viewed-in-1-week-time-period/
Share on other sites

So I am using this to get the number of views in a week... but do I set 'date' as a normal 'date' type in phpmyadmin? And I don't see how it would know when the views were viewed unless it logged each view in it's own row.

 

<?php
$period = 604800;
$query = "SELECT * FROM `games` WHERE `date` < '".(($now = time()) - $period)."'"; 
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){ 

$views=$row['views'];

}
?>

getting back to your original question every time a game is "viewed" add  a row to a mysql table called Game Views

 

Then Just find the COUNT('Game_Views'), Game_Name from `table` where Date_Played <= NOW()-64000

 

and you have it.

 

Probably a good Idea to flush this every so often as it could get huge.

 

then you don't have a "Good" continuous method you will need to do something that counts the number of hits for each game on each day and simply do addition to that count

 

GameName

Day

Hits

 

and then add up the counts for each game in the given Days frame (Or week)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.