Jump to content

php mysql update statement


pmonty

Recommended Posts

My statement

mysql_query("UPDATE videos SET views = views + 1 WHERE code = '$video'");

it seems to be updating the view count by 1 but the moment that i go to another video then another it starts to increase by 1 or more every time during that session. I am killing the mysql connection to so not sure whats its doing. Any idea guys?

Link to comment
Share on other sites

Try getting the session id. session_id();Add it to an active viewers table with the video code viewed and the session id used to view that video.If you find a match then it was viewed by that user.Clear this once a day or it will stack up. There may be a more elegant solution.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...