tags:

views:

30

answers:

2

I want to create and display a value which is increasing by a fixed amount per second.

I have the following variables in my PHP file:

$AccountValue=220000; $IncreasePerSecond=15;

So for example when the page loads the value would be 220000 after one second the value would be 220015 after another second 220030 ....etc

thanks in advance

+1  A: 

It's not the full answer but it should give you the basis:

var count = 0;
setIncrement("doSomething()", 1000);
function doSomething()
{
  document.getElementById("my_div").innerHTML = ++count;
}

See http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/

Wernight
+1  A: 

I think it's best to write this in javascript, i.e. client-side( as Wernight already shows in his answer.

On the server-side you can record the point at which the seconds start to increase. Then when the page gets requested again you can calculate on the server-side the amount of seconds that are between the starting point and the current time.

immeëmosol