Jump to content

Variable to capture elapsed seconds


chasethemetal

Recommended Posts

Hey!I have a script that needs to perform 3 different mySQL inserts based on time the scripts been on. My theory is this:$x = (seconds, this needs to be constantly changing... so if i were to echo it, it would be a moving timer)if $x == "10" { insert into sql...}if $x == "30" { insert into sql... }if $x == "90" { insert into sql... }I am trying to record the length someone is on the script... And those are my 3 check points. Any help would be awesome!!

Link to comment
Share on other sites

PHP stops executing as soon as the page loads, so you can't count the time the user has been on the page with it.You can use Javascript timing to send AJAX requests to the server on certain time intervals.

Link to comment
Share on other sites

I figured it out. I basically have a JavaScript counter that loads in a <div> when a user clicks a button. Inside that counter I have it load into yet another PHP page where I use the _GET function to get the seconds as the count up... So it reloads this little php page every second thus changing the value of X every page load. Ba Bang!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...