Muncey Posted July 11, 2007 Share Posted July 11, 2007 Basically im doing this kind of game thing where each member (who has registered and is in the database ect) goes onto a series of pages trying to figure out the answer to whatever. Basically i want to be able to calculate how long each person has taken on 1. each level and 2. altogether. Each level isn't a must, a must is basically an altogether total time for each member. I only want the time to increase on certain pages, the level pages. I'd probably like the time to be kept in the database too. In the database is a members table with a field labeled "level". Each time they complete a level the level goes up one in the database, this way the person can only access a further level if they have completed the previous. Im not asking someone to make me this, im asking for someone to point me in the direction of learning about this because as of yet i have no idea how to calculate time spent on certain pages. (For example on this forum.. Total time logged in: 3 hours and 9 minutes.) Thanks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2007 Share Posted July 11, 2007 Use a javascript clock kinda idea on an input and then when the answer is submitted you got the time right there as a form variable Quote Link to comment Share on other sites More sharing options...
Muncey Posted July 11, 2007 Author Share Posted July 11, 2007 I'm terrible at javascript so this will give me a reason to brush up on it lol Thanks for the reply, i wasn't sure if it could be done in PHP or not.. i looked about and saw some reference to javascript. Edit: after some quick reading i realise that the timer will count up and obviously stop when they hit a button or something... so really all the person would need to do is find out the answer, hit refresh and put in the answer therefore completing the level within a few seconds. Do you know if it could update a number on the database every second that goes by... that way when they refresh they don't get rid of what they already done because it was stored in the database. I need to store the seconds without them doing anything. Is there a way of doing this? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2007 Share Posted July 11, 2007 yeah you can probably find a javasciprt clock script I had one and I don't know where it went sorry, but its not hared and it works by updating the value of a form variable so if your page processes via a form it works perfectly if not you might need to make a link that is dynamically linked to that time. Quote Link to comment Share on other sites More sharing options...
Muncey Posted July 11, 2007 Author Share Posted July 11, 2007 Would the clock stop and save the variable if the person suddenly closed the page or something though? cause they may spend an hour on one page then click off and the timer wouldn't save and jsut restart therefore not showing the true time the person was on there... (more explained in my previous post, i edited it) Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 11, 2007 Share Posted July 11, 2007 not, but what may be a better solution is to run an ajax's query every minute that says current question time spent etc etc, Quote Link to comment Share on other sites More sharing options...
Muncey Posted July 11, 2007 Author Share Posted July 11, 2007 Thanks i thought ajax would probably be the way around it lol. Ill look into this. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted July 11, 2007 Share Posted July 11, 2007 If you store the contents of time() at the start and subtract it from time() at the end you'll get the number of seconds they took. If there are page refreshes involved between recording both values then you could store the first in a session which will be remembered from page to page. Quote Link to comment 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.