Galahad Posted September 6, 2012 Posted September 6, 2012 Hey, I'm in the middle of creating a website and i am stuck. Basically, I have added a view count to a page so when a user clicks on a page, it submits a query to update the view count. Now the problem is that if people constantly hit refresh, the view count will go up every time that page loads for even the slightest second. So I'm wondering if it's possible to make it so that the query only submits after the user has been on the page for a certain amount of time (5 seconds). Thanks Quote
Galahad Posted September 6, 2012 Author Posted September 6, 2012 Use the sleep function? How would i use that function to stop a query from submitting after 5 seconds? ... its probably easy but I've just started php again and i have almost forgot everything. Quote
sniko Posted September 6, 2012 Posted September 6, 2012 /* - code before query */ sleep(5); /* - do query - rest of code */ Quote
Galahad Posted September 6, 2012 Author Posted September 6, 2012 /* - code before query */ sleep(5); /* - do query - rest of code */ Thanks i've just tried it but it's not the solution i'm looking for. That just makes the page take 5 seconds longer to load Quote
Galahad Posted September 6, 2012 Author Posted September 6, 2012 Then why not use Google Analytics? I'm making a image website and i want to show the amount of views that image has on the page so i guess that wouldnt work...unless theres a way to show the views of each individual page Quote
Octarine Posted September 6, 2012 Posted September 6, 2012 (edited) Sessions would help here; for example... Edited September 6, 2012 by Octarine Quote
sniko Posted September 6, 2012 Posted September 6, 2012 Read this thread: http://www.fly2.co/WE0Yw819 and view the second reply. - or - do this: http://www.fly2.co/WQ5Nw548 Quote
Galahad Posted September 6, 2012 Author Posted September 6, 2012 Sessions would help here; for example... Brilliant! It works! Thanks alot :D Quote
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.