How to get the number of views for a topic in a blog

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
syamswaroop
Forum Newbie
Posts: 19
Joined: Fri May 01, 2009 1:31 am

How to get the number of views for a topic in a blog

Post by syamswaroop »

I have devolped a blog with php . now i have saved that blog content in a php file
now how to know how many views are there for that php file and also basically what is exactly meant by view and how to rate that blog using php
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: How to get the number of views for a topic in a blog

Post by jackpf »

You could have a field called `Counter` or something for each entry in the database. You could then increment the counter each time someone visits that entry.

You might also want to set a cookie that expires in 10 minutes or something, and only update if that cookie doesn't exist though, because someone could just hold down f5 and completely invalidate your stats.
syamswaroop
Forum Newbie
Posts: 19
Joined: Fri May 01, 2009 1:31 am

Re: How to get the number of views for a topic in a blog

Post by syamswaroop »

Thank you very much
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: How to get the number of views for a topic in a blog

Post by jackpf »

No problem :)
Post Reply