Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.