Mr Chris Posted June 17, 2009 Share Posted June 17, 2009 Hello, I have a counter on my page which increments a column in my database every time a story on my site is viewed: $result = mysql_query("SELECT * FROM stories WHERE story_id=".$id); $row = mysql_fetch_array($result); $i = $row['my_count']; $i++; $query = "UPDATE stories SET read_count = '$i' WHERE story_id=".$id; $result = mysql_query($query); Is there anyway I could make it a bit better to not allow for things like a user sitting there and hitting refresh 15 times, and bots visiting the page, things like that really? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/162596-check-how-many-times-an-article-is-viewed/ Share on other sites More sharing options...
Maq Posted June 17, 2009 Share Posted June 17, 2009 You can use sessions to ensure they are only counted once. Not sure about the bots issue. For crawlers, which I'm not even sure if they would be counted, you would have to conditionally detect them. Try Google, something like: Detect Crawlers. Quote Link to comment https://forums.phpfreaks.com/topic/162596-check-how-many-times-an-article-is-viewed/#findComment-858148 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.