Jquery statement to tally total of something happening every 3.6 seconds

At the top of every page, I need to list how many children globally have died of malnutrition (one every 3.6 seconds, I know, HORRIBLE thing to think about). the old site was refreshing the page ina iframe with IE clicking every time there is a refresh, not a good solution. Can I do this with AJAX and jquery do this? I create a session to store the variable, but I have no idea how to do the rest of this. I have started reading a book on AJAX and have read some tutorials on jquery, but I need this soon.
I am an intermediate PHP programmer, but a newbie in JS. Thank you.

do i understand you right. you have a website that has some start variable and calcualtes the time until now in seconds and divides this number through 3.6 and this number is displayed in the browser?

why don't you do the calcualation and the displaying of the number in the browser. some kind of counter.

for this you wouldn't need a server-request every 3.6 seconds.

otherwise if you want to push information to browsers you should have a look at the comet/bayeux-procol :http://www.cometd.com/

the code for a counter would look something like this (i don't know the jquery-framework, so i'm using document.getElementById ...)

the code is not tested. it should just give you an idea how to get this done.

<html> <head> <script type="text/javascript"> function calcMalnutritionDeaths() { var numberOfDeaths=0; // calculate the number of children that have died from malnutrition until now // numberOfDeaths = (now - definedDate in seconds ) / 3.6 return numberOfDeaths; } function showMalnutritionDeathsTimer() { // display the updated number document.getElementById("someDiv").innerHTML=calcMalnutritionDeaths() + " deaths since 01.01.1900"; } // set the Timer to update the MalnutritionDeaths to be executed every second window.setInterval("showMalnutritionDeathsTimer()", 1000); showMalnutritionDeathsTimer(); </script> </head> <body> <div id="someDiv">activate Javascript to see this counter</script> </body></html>

Thanks to ragerino and Kokoglen for your suggestions! This was a bad time to ask this question, because I am about to be out of the country (US) for 2 weeks. I will try these suggestions when I return.
Kokoglen - how will I make this work across all the pages on the website? I am not sure how to integrate it into the session variable. I have printed out these solutions and will study them while I am away.
Thanks again, I will be back on top of this on February 16.

Just put the script into a counter.js file and then include the script on all your pages.
If you want it to be totally accurate, when the page loads, just declare the variable (count) with the real number off the server. Not sure why you need to have sessions involved.

I thought I needed sessions to get the time at any particular moment and subtract current time from the time the person logged onto the website. This counter has to continue working on every page that the user goes to, it keeps ticking away. Do I NOT need a session to do that? How would I get the time when the user first arrives on the website and keep that date the same, then keeping getting the current time?

How do you get the first count on the first page? Just repeat that for every page.

Detail: The server would give the current starting count (it knows the current time and the current # of malnurished kids) then the browser (as Ive demonstrated) counts every 3600 milliseconds) to add one to the count. The next page he goes to will start the process over, always with the correct server side beginning count.

I dont understand what time the user arrived has anything to do with the number of malnurished kids.

Again
1. Server renders page with current count start.
2. Client incremends every 3600 ms.
3. new page does the same thing.

Sorry I didn't make this clear from the beginning, it is the number of kids who have died since the user logged onto the website. You can see this in action in the clunky version that was done in php. The website owner didn't want the page to refresh so often, so it only refreshes every 30 seconds. Nothing displays until it refreshes once unless you go to a different page. It is in the gray bar under the header.www.projecthealthychildren.org

This one is pretty easy to set and get. SO some psuedo code
1. check for cookie, if it has a time , then get the time. Have the cookie expire in like 12 hours to let it reset if you want.
2. if it doesn't have one, set the cookie with the current time http://www.javascriptkit.com/jsref/date.shtml
3. subtract the cookie time from the current time.
4. get the start count for that page and set the variable.
5. then the demo works.

but this is why I grabbed the initial time the user comes to the website, and stored it in a session variable, Some people don't accept cookies, right?
I just printed out an article on setting a persistent cookie, I have never done cookies before. I will work on this on my trip.
Thanks for your help!

Ahh... sorry, I've been living in Java land.... I was thinking that time() returned in milliseconds. It appears that in PHP it is only in seconds, and therefore the divide by 1000 was uncalled for. I am also thinking that we should apply a floor() operation on the result since PHP has such loose type casting (we want to make sure we have an integer result). Try replacing the php code with the snippet below.

I also had a few observations on the jQuery code as well... I noticed that you're appending the counter twice, like this:
$('#counter').append("<span>" + count + "</span><span>" + count + "</span>");

This should only be:
$('#counter').append("<span>" + count + "</span>");

I also think that the text() method will actually replace the current contents of the matched element, so you should be able to replace this:
$(this).siblings("span").empty().text(count);
with
$(this).siblings("span").text(count);

Lastly, sorry for the multiple posts. But one more error.
$('#counter').append("<span>" + count + "</span><span>" + count + "</span>");
Line 49
I had TWO spans. Go back and check out my source. They are required for the cycle plugin to have more than one thing to cycle. Basically, I am swapping the two spans and after each one moves, I add one to the other span. If you don't have the second span, it will not have anything to cycle and no number will get added.

I copied and pasted the source of that file. Should I be using that one (not messed up) instead of the other reference to jquery? I took out the reference to jquery-latest, but it is still not working
If the jquery-latest is messed up, jquery.cycle.php is probably also messed up. Is there some way I can get those pages without copy/pasting them?

I will get these tools.
Meanwhile, the counter starts with the correct number when I refresh the page, but then it just ticks off the seconds, instead of advancing one every 3.6 seconds. I don't know how to fix that.
Thanks

I removed all the extraneous references, and it is still counting the number of seconds, not increasing one every 3.6 seconds. I don't see a place where the number of seconds elapsed has been divided by 3.6, is there one?