desithugg Posted April 2, 2007 Share Posted April 2, 2007 <?php for($i=1; $i<60; $i++) { sleep(1); echo $i.", "; ob_flush(); flush(); } echo "At:".$i; ?> Basically what it is supposed to be is a lil counter that counts till 60 seconds Umm i saw the flush function somewhere on the forums couple of days ago and decided to try it out a bit. What I'm trying to do is have it count untill 60 seconds. I want to display a list like "1, 2, 3, 4, 5, 6, 7" and I also want it to show like what number it's at in this case "At:7" <-- i want this to change as the countdown goes up is this possible? Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/ Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 First of I didn't understand your question compleately. are you trying to do this ?? <?php for($i=6; $i>0; $i--) { sleep(1); echo $i.", "; ob_flush(); flush(); } echo "At:".$i; ?> Output 6, 5, 4, 3, 2, 1, At:0 Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219731 Share on other sites More sharing options...
desithugg Posted April 2, 2007 Author Share Posted April 2, 2007 umm no maybe i didn't word it right <?php for($i=1; $i<60; $i++) { sleep(1); echo $i.", "; ob_flush(); flush(); } echo "At:".$i; ?> It's not a count down sorry it's a count up counts until 60 lets say it is at 7 and it's showing "1, 2, 3, 4, 5, 6, 7" I want it to show the number it is at so in this case i want it to show "At: 7" at the bottom know what i mean? so if it was at like 4 "1, 2, 3, 4" it would show at the bottom "At: 4" Well it's kind of hard to explain, the only problem is the number "At: whatever" isn't changing Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219736 Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 Show an Example Output That You Want Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219751 Share on other sites More sharing options...
obsidian Posted April 2, 2007 Share Posted April 2, 2007 It sounds like you're wanting a live counter in PHP. That's not going to happen, though. PHP is entirely server side, so when you run things like sleep(), you are pausing the execution of the script on the server, not on the browser. You'd be much better off using Javascript for live timing events like this. Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219753 Share on other sites More sharing options...
desithugg Posted April 2, 2007 Author Share Posted April 2, 2007 It sounds like you're wanting a live counter in PHP. That's not going to happen, though. PHP is entirely server side, so when you run things like sleep(), you are pausing the execution of the script on the server, not on the browser. You'd be much better off using Javascript for live timing events like this. kk thanx I was aware about javascript but was just wondering if it was possiable in php Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219854 Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 php is a Serverside Language. The story of php ends compleately when the page compleately gets loaded to the browser. After that there is no php at all. so if there is no php how can it do something. Link to comment https://forums.phpfreaks.com/topic/45257-umm-a-lil-question/#findComment-219857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.