adhbvklwqdbviabjiawdnbij Posted September 8, 2011 Share Posted September 8, 2011 With this script: <?php $i=1; while($i<=5) { echo "The number is " . $i . "<br />"; $i++; sleep(3); } ?> I get: The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 How can I make this dynamic. For example: First it would get: The number is 1 After 3 seconds... The number is 2 After 3 seconds... The number is 3 ....... Quote Link to comment Share on other sites More sharing options...
TOA Posted September 8, 2011 Share Posted September 8, 2011 *edit* didn't read full post So you're just not getting the time between echo's? Quote Link to comment Share on other sites More sharing options...
litebearer Posted September 8, 2011 Share Posted September 8, 2011 perhaps this may help... http://www.webmasterworld.com/php/3554664.htm Quote Link to comment Share on other sites More sharing options...
voip03 Posted September 8, 2011 Share Posted September 8, 2011 1.Your code works fine 2 After 3 seconds...it will not make any different, make it at least 30sec. http://www.plus2net.com/php_tutorial/sleep.php Quote Link to comment Share on other sites More sharing options...
Adam Posted September 8, 2011 Share Posted September 8, 2011 I think what err.. adhbvklwqdbviabjiawdnbij is after, is the text appearing dynamically on the page - i.e. JavaScript. It's very simple to do. Run this and let us know if it's what you're after... <div id="output"></div> <script type="text/javascript"> var i = 0; var timer = setInterval(function() { document.getElementById('output').innerHTML += 'The number is ' + ++i + '<br>'; if (i == 5) { clearInterval(timer); } }, 3000); </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.