Jump to content

Archived

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

lilywong

Auto increment a number for every 10 seconds

Recommended Posts

How to automatically increase a number by 1 for every 10 seconds ?
for eg, the current number is 10, after 10 seconds, it will automatically added to 11;and after 10 seconds, it will automatically added to 12.

and the page will refresh automatically as well.

Share this post


Link to post
Share on other sites
I am not sure if this shall work for what you are trying..but test it..
[code]
<?
$num = strip_tags($_GET['num']);
echo $num;
$num=$num+1;
print "<META HTTP-EQUIV=Refresh CONTENT=\"10;url=yourpage.php?num=$num\">";
?>
[/code]

Share this post


Link to post
Share on other sites
why not calculate it based on the actual times so $start=time()  $end=time() $start-$end give you millaseconds (i think its millaseconds) diference so then do your math from there

Share this post


Link to post
Share on other sites
[code]<?php
$num = 0;
while(1==1)
{
sleep(10);
$num++;
}
?>[/code]

Will increase by 1 every ten seconds.

Share this post


Link to post
Share on other sites
[quote author=Daniel0 link=topic=87013.msg436362#msg436362 date=1158558789]
[code]<?php
$num = 0;
while(1==1)
{
sleep(10);
$num++;
}
?>[/code]

Will increase by 1 every ten seconds.
[/quote]

Unfortunately, though, you will never see the number as the script will just hang until it eventually times out

Share this post


Link to post
Share on other sites

×

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.