Jump to content

Tracking how many times a row of data is viewed


PTS

Recommended Posts

I have two tables created in my database: "news" and "newsviewed"

 

news is our news engine for posting stories to our site and newsviewed is a new table we created to track how many times a story is viewed so we can offer our visitors features like favorite stories, most viewed, etc.

 

Each time a visitor loads a story on our site (/fullstory.php?newsid=####), I want to create a row in the newsviewed table that automatically inserts a row of data (id, newsid, timestamp).

 

Is there a php statement that I can do to make this happen automatically each time a story is loaded? Any guidance or direction would be greatly appreciated.

 

Also, is this an efficient way of doing this? I know I could add a field to the news table called counter and then update that field to go up by one but I want to have the ability to show most popular stories by date.

Link to comment
Share on other sites

Guest
This topic is now 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.