Jump to content

umm a lil question


desithugg

Recommended Posts

<?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

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

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

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

Archived

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

×
×
  • Create New...

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.