Jump to content

Time Spent


Muncey

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.