View Full Version : Creating a loading page
FlashNewby
November 8th, 2005, 01:26 PM
Hi all,
I need to know how to create a loading page while processing is going on in the background. Basically to water it down I have a php page that when click saves content to a database, while it's doing this I need to have another php/html page display that says processing or whatever. Once processing is done the page will forward to another page and so on.
Thanks
ironikart
November 8th, 2005, 08:32 PM
easiest way, although possibly not the best, is to pop up a window that says loading, then once the page is done loading use javascript on the parent window to close the pop-up....
actually, that's a terrible idea - but if you're doing this all through the browser you are limited.
Why don't you just rely on the browser's loading window to tell your users that a page is loading?
SlowRoasted
November 8th, 2005, 09:53 PM
Im guessing he wants a loading screen like vbulletin has while your post is processed.
hl
November 8th, 2005, 10:05 PM
yeah like a flash preloader, only for a php page. to be honest i've been thinking about this for a while myself. one time i found something that's like a module of php. i'll have to find it though
*goes to google*
eirche
November 9th, 2005, 10:47 AM
try this, tho i still get notice messages.
echo "<pre>";
echo "countdown begins\r\n";
for ($i = 10; $i > 0; $i--)
{
sleep(1);
echo $i . "\r\n";
ob_flush();
flush();
}
echo "Launch";
header("Location: moonbase.php");
echo '</pre>';
FlashNewby
November 9th, 2005, 12:23 PM
SlowRoasted this is exactly what I want to do
Im guessing he wants a loading screen like vbulletin has while your post is processed.
eirche I'll try this and see. The only issue I see is that we are assuming it could take 10 seconds to load which it may or may not, know what I mean
for ($i = 10; $i > 0; $i--)
{
sleep(1);
echo $i . "\r\n";
ob_flush();
flush();
}
Thanks to everyone for the input let me know if you find anymore info, I've been trying to put my hands around this...
eirche
November 9th, 2005, 01:51 PM
don't take my example literally 10 seconds. it's about the flush() function. normally php spits out its output at once AFTER script execution is completed. you can use flush() to spit out some output while it is still being executed.
how about this?
echo "processing ... ";
ob_flush();
flush();
do_some_tedious_task();
echo "task one completed";
ob_flush();
flush();
do_something_inefficiently();
echo "task two completed";
ob_flush();
flush();
FlashNewby
November 9th, 2005, 03:15 PM
Ok what I'm doing is echoing out some simple html that says loading while I'm waiting for the page to flush. But when the page finishes flushing I don't want the Loading text to stay on the page, somehow I need it to disappear once the page is done loading.....
eirche
November 9th, 2005, 05:20 PM
header("Location: whateverpage.php");
FlashNewby
November 9th, 2005, 06:21 PM
I don't want to leave the page that has the loading image. When page that has the loading code is done and the html is flushed to the page, I want to somehow remove the Loading text from the same page.
eirche
November 9th, 2005, 07:41 PM
use javascript
<div id="progresslog">
task one completed<br>
task two completed<br>
</div>
<script type="text/javascript">
document.getElementById('progresslog').style.displ ay = 'none';
</script>
hl
November 9th, 2005, 09:58 PM
the thing that i find with this.. it's not exactly loading with that flush. it'll just count to ten and run away. therefore enlarging the time it takes for the whole page to load.
FlashNewby
November 10th, 2005, 04:58 PM
You know you have a good point. So basically with this loading feature I'm just unnecessarily extending the time it takes for the page to display...:-/
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.