jatter Posted October 13, 2007 Share Posted October 13, 2007 I'm trying to make a countdown script, but I'm having a problem with it. I want that the script refreshes itself every second and not the page.This is what I have till now. <?phpsession_start();?><html><head><title> countdown </title></head><body><?php$start=40;while($start>=0) { echo "00:00:" . $start; $start--; }?> I'm not sure if it's possible in php, but I'd appreciate it if you could find a solution in php. Link to comment Share on other sites More sharing options...
murfitUK Posted October 13, 2007 Share Posted October 13, 2007 Not really possible with php. Once the script has run and the output has been sent to the browser - that's it, finished. You need to find some way to get the user's browsers to do it. Perhaps some sort of javascript. Have you had a look at dynamic drive? Try this:http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm Link to comment Share on other sites More sharing options...
justsomeguy Posted October 13, 2007 Share Posted October 13, 2007 I want that the script refreshes itself every second and not the page.The "script" and the "page" are the same thing. Link to comment Share on other sites More sharing options...
Synook Posted October 14, 2007 Share Posted October 14, 2007 The "script" and the "page" are the same thing.This is always so when using an S3L. Link to comment Share on other sites More sharing options...
jatter Posted October 14, 2007 Author Share Posted October 14, 2007 Ok, thanks for the awnsers. It seems that I have to do it with Javascript. Link to comment Share on other sites More sharing options...
Juddling Posted October 14, 2007 Share Posted October 14, 2007 With javascript try using, setTimeout() / setInterval() Link to comment Share on other sites More sharing options...
jatter Posted October 16, 2007 Author Share Posted October 16, 2007 With javascript try using, setTimeout() / setInterval()Yeah I saw something like that somewhere, I only have to figure out how to make it stop when it is at 0 seconds. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 16, 2007 Share Posted October 16, 2007 The clearInterval function will stop a timeout created with setInterval. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.