473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Progress indicators on a page...?

no
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.

Thanks
Chris R.
Jun 20 '06 #1
9 1795
no@emails.thx writes:
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.


the php function flush() does the trick

--
Henrik Hansen
Jun 20 '06 #2
On Tue, 20 Jun 2006 13:07:13 +0000, no wrote:
I have a PHP script that updates a very large table and in the code I echo
some text to show the progress of the update but the text only appears
when the page has finished displaying.

Is there any way (through html headers?) to force the page to update in
real time, while the PHP script is still executing?


I'd say go with AJAX. It's really not hard to learn, and as it's a
non-essential function if people don't have it, they can do without.

You could then provide an estimate of the time to completion (using number
of rows complete, number to be completed and number completed in last
second).

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Jun 20 '06 #3
no@emails.thx wrote:
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.

Thanks
Chris R.


As Henrik indicated, flush() works. You may also need to call ob_flush().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 20 '06 #4
no
On Tue, 20 Jun 2006 15:49:03 GMT, Andy Jeffries
<ne**@andyjeffries.co.uk> wrote:
On Tue, 20 Jun 2006 13:07:13 +0000, no wrote:
I have a PHP script that updates a very large table and in the code I echo
some text to show the progress of the update but the text only appears
when the page has finished displaying.

Is there any way (through html headers?) to force the page to update in
real time, while the PHP script is still executing?


I'd say go with AJAX. It's really not hard to learn, and as it's a
non-essential function if people don't have it, they can do without.

You could then provide an estimate of the time to completion (using number
of rows complete, number to be completed and number completed in last
second).


Thanks Andy

I have had a look at Ajax ... a bit daunting but I might give it a
try, as the site I am developing would benefit from the look and feel
of a true application.

Chris R.
Jun 22 '06 #5
no
On Tue, 20 Jun 2006 12:32:23 -0400, Jerry Stuckle
<js*******@attglobal.net> wrote:
no@emails.thx wrote:
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.

Thanks
Chris R.


As Henrik indicated, flush() works. You may also need to call ob_flush().


Hi Henrik & Jerry

I tried ob_flush() followed by flush(), as suggested but it dodn't
make a difference - still got a blank page for 5 minutes than SPLAT! a
full page listing all the imported records.

Another poster on a different group suggested it might be because I
use nested tables to arrange the content on the page. Apparently
browsers often refuse to display the cells until the </table> is
received.

With that in mind I might look at using Ajax or just reworking the
pages using CSS to position blocks of content on the page. :o)

Cheers, Chris R.
Jun 22 '06 #6
no@emails.thx wrote:
On Tue, 20 Jun 2006 12:32:23 -0400, Jerry Stuckle
<js*******@attglobal.net> wrote:

no@emails.thx wrote:
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.

Thanks
Chris R.

As Henrik indicated, flush() works. You may also need to call ob_flush().


Hi Henrik & Jerry

I tried ob_flush() followed by flush(), as suggested but it dodn't
make a difference - still got a blank page for 5 minutes than SPLAT! a
full page listing all the imported records.

Another poster on a different group suggested it might be because I
use nested tables to arrange the content on the page. Apparently
browsers often refuse to display the cells until the </table> is
received.

With that in mind I might look at using Ajax or just reworking the
pages using CSS to position blocks of content on the page. :o)

Cheers, Chris R.

Not Php, but .....

If you want to use an animated gif as a "dumb" progress bar, here is
some css that does it.
http://www.cssplay.co.uk/menu/start_gif.html (using a.hover and a.click)

You can also use Javascript to start and stop an animated gif (let me
know if you want to see this method).

Or another Javascript method:
http://www.irt.org/script/1225.htm

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Everyone's journey should be different,
so that we all are enriched
in new and endless ways
*****************************
Jun 22 '06 #7
no@emails.thx wrote:
On Tue, 20 Jun 2006 12:32:23 -0400, Jerry Stuckle
<js*******@attglobal.net> wrote:

no@emails.thx wrote:
Hi

I have a PHP script that updates a very large table and in the code I
echo some text to show the progress of the update but the text only
appears when the page has finished displaying.

Is there any way (through html headers?) to force the page to update
in real time, while the PHP script is still executing?

I have seen similar thngs on webmin pages when it is downloading
updates and it is nothing fancy (graphics etc) - just text.

Thanks
Chris R.


As Henrik indicated, flush() works. You may also need to call ob_flush().

Hi Henrik & Jerry

I tried ob_flush() followed by flush(), as suggested but it dodn't
make a difference - still got a blank page for 5 minutes than SPLAT! a
full page listing all the imported records.

Another poster on a different group suggested it might be because I
use nested tables to arrange the content on the page. Apparently
browsers often refuse to display the cells until the </table> is
received.

With that in mind I might look at using Ajax or just reworking the
pages using CSS to position blocks of content on the page. :o)

Cheers, Chris R.


Chris,

Ah, nested tables. That does add a new dimension to the problem.

I use ob_lush() and flush() when I have long-running tasks. But I generally
don't like to use tables for layout, either. It should work a lot better with CSS.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 23 '06 #8
On Thu, 22 Jun 2006 17:54:44 +0000, no wrote:
I have had a look at Ajax ... a bit daunting but I might give it a try, as
the site I am developing would benefit from the look and feel of a true
application.


Hi Chris,

Send me an email if you like. I sent a few emails recently to another guy
of this group explaining AJAX and how to use it easily from PHP. I can
forward those emails to you if you like (removing any parts that would
identify the site he's working on).

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Jun 23 '06 #9
I have one, without using AJAX.

1. Put this code in the header:
<div id="liveProgress"></div>

2. In your PHP code, add this function:
function setProgress($x) {
echo "<script type=\"text/javascript\">"
. "document.getElementById('liveProgress').inner HTML = '$x';"
. "</script>";
flush();
}

3. In your loop, type some code like this:
setProgress("Loading... ???%");

Edit message above to whatever you want.

Note that calling too much times of setProgresss function may extremely
slowdown client's browser and eats huge amount of bandwidth. I
recommend to update status every 50-100 loop.

------------------------------------------------
// Example Code:
<html><head><title>Progress Test</title></head><body>
<div id="liveProgress"></div>
<hr /><?php
function setProgress($x) {
echo "<script type=\"text/javascript\">"
. "document.getElementById('liveProgress').inner HTML = '$x';"
. "</script>";
flush();
}
$max = 7;
for ($i = 0; $i < $max; $i ++) {
echo 'Loop #' . ($i + 1) . ' of ' . $max . '<br />';
setProgress('Loading...' . round(($i / $max) * 100) . '%');
sleep(1);
}
setProgress('Finished!!');
?>
</body></html>

Jun 23 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: James Morton | last post by:
I have a Static DataSet in a class file that I am using globally between a few forms. The main form populates the dataset through a menu option which invokes ReadXML in the class file to populate...
1
by: Stefan | last post by:
I'd like to display the keyboard navigation indicators in my C# application without the user having to press the Alt key and regardless of the machines global setting (Hide keyboard navigation...
4
by: Kenneth Keeley | last post by:
Hi, I have a page that uploads files to my server and I wish to display a "Please wait while uploading" page to the user while the file is uploading. I have been able to redirect the user once the...
3
by: SpamProof | last post by:
I got an animated gif that is a barber pole spinning that I want to use as a progress bar. The problem is that is stops spinning (shows 1 frame) when my browser is processing a submited request...
6
by: Ernie | last post by:
I have a unique issue... We are using Microsoft Commerce Server and Content Manager on our eCommerce Site. I have been requested to display a login status (Pic that says Please Wait) in a control...
6
by: Samantha | last post by:
Hi. hi have a custom created smooth progress bar (Pbar) control and i wanted to know how i can reset the bar to 0 after the bar has run to completion. The pbar uses a timer control to...
1
by: daniel_xi | last post by:
Hi all, I am running a VS 2003 .NET project on my client machine (Win 2000 SP4, ..NET framework 1.1), running an ASP.NET application on a remote web server (Win 2000 Server, IIS 6.0, .NET...
15
by: eladla | last post by:
Hi! I am creating a composite control the does some of it`s own data access. I want to display a progress bar between the time the page is loaded and the control place holder is displayed and...
14
by: rellaboyina | last post by:
Hi I need a small help from you all. I had a form which consists of 2 fields username and password to be entered. It also consists of a Log-in button. Once we enter the username and password, if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.