Jump to content


Photo

Auto increment a number for every 10 seconds


  • Please log in to reply
4 replies to this topic

#1 lilywong

lilywong
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 28 February 2006 - 03:17 AM

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.

#2 Dobakat

Dobakat
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 18 September 2006 - 03:54 AM

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


#3 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 18 September 2006 - 05:40 AM

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

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 18 September 2006 - 05:53 AM

<?php
$num = 0;
while(1==1)
{
	sleep(10);
	$num++;
}
?>

Will increase by 1 every ten seconds.

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 18 September 2006 - 10:28 AM

<?php
$num = 0;
while(1==1)
{
	sleep(10);
	$num++;
}
?>

Will increase by 1 every ten seconds.


Unfortunately, though, you will never see the number as the script will just hang until it eventually times out
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users