lilywong Posted February 28, 2006 Share Posted February 28, 2006 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. Link to comment https://forums.phpfreaks.com/topic/3719-auto-increment-a-number-for-every-10-seconds/ Share on other sites More sharing options...
Dobakat Posted September 18, 2006 Share Posted September 18, 2006 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] Link to comment https://forums.phpfreaks.com/topic/3719-auto-increment-a-number-for-every-10-seconds/#findComment-93798 Share on other sites More sharing options...
markbett Posted September 18, 2006 Share Posted September 18, 2006 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 Link to comment https://forums.phpfreaks.com/topic/3719-auto-increment-a-number-for-every-10-seconds/#findComment-93811 Share on other sites More sharing options...
Daniel0 Posted September 18, 2006 Share Posted September 18, 2006 [code]<?php$num = 0;while(1==1){ sleep(10); $num++;}?>[/code]Will increase by 1 every ten seconds. Link to comment https://forums.phpfreaks.com/topic/3719-auto-increment-a-number-for-every-10-seconds/#findComment-93813 Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 [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 Link to comment https://forums.phpfreaks.com/topic/3719-auto-increment-a-number-for-every-10-seconds/#findComment-93875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.