Tjorriemorrie Posted March 28, 2008 Share Posted March 28, 2008 Hey, for simplicity: the user is at page1. from there it's redirected to page2. then page2 will redirect it to page1. I have the redirection going fine, but the problem is that I want page1 to show "Loading...", then wait for 3seconds and then start loading page1. So far I have: (note I'm only getting my toes wet, just trying to see how things work, thus redirect excl). <?php $goto = $_SESSION['URLvisited']; if (!$CookieIsSet) { echo "Cookie could not be set"; die(); } else { for ($i = 1; $i <= 10; $i++) { echo "Loading " . $i; sleep($i); } } I'm just trying to get it to work with that for loop. But it doesn't show each 'loading'. Page2 stays blank and then throws the timeout error (which is fine). How can I get echo's to show on the screen with sleep() inbetween? Secondly, how is my script different from the example in the manual?? (coz mine isn't working ) <?php // current time echo date('h:i:s') . "\n"; // sleep for 10 seconds sleep(10); // wake up ! echo date('h:i:s') . "\n"; ?> Link to comment https://forums.phpfreaks.com/topic/98355-sleep-how-to-use-it-for-display-purposes/ Share on other sites More sharing options...
BlueSkyIS Posted March 28, 2008 Share Posted March 28, 2008 i'd use a meta refresh instead of trying to hack it together with PHP. send visitor to page 1 with meta refresh to the next page (even the same page), displaying "Loading..." or whatever. Link to comment https://forums.phpfreaks.com/topic/98355-sleep-how-to-use-it-for-display-purposes/#findComment-503365 Share on other sites More sharing options...
Tjorriemorrie Posted March 28, 2008 Author Share Posted March 28, 2008 i'd use a meta refresh instead of trying to hack it together with PHP. send visitor to page 1 with meta refresh to the next page (even the same page), displaying "Loading..." or whatever. Thanks BlueSkyIS. The other thing is that I want to put an if in. True will let it load and false won't let it load. So I was hoping this would've worked I guess I have to just ignore the sleep all together. Sigh, I hate it when I can't implement functions Link to comment https://forums.phpfreaks.com/topic/98355-sleep-how-to-use-it-for-display-purposes/#findComment-503403 Share on other sites More sharing options...
redarrow Posted March 28, 2008 Share Posted March 28, 2008 php way relable way......... <?php ob_start(); header("Refresh: 3; url=index.php") ob_flush(); Link to comment https://forums.phpfreaks.com/topic/98355-sleep-how-to-use-it-for-display-purposes/#findComment-503408 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 That's pretty much the same as doing meta refesh. Link to comment https://forums.phpfreaks.com/topic/98355-sleep-how-to-use-it-for-display-purposes/#findComment-503445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.