473,856 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1817
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*******@attgl obal.net
=============== ===
Jun 20 '06 #4
no
On Tue, 20 Jun 2006 15:49:03 GMT, Andy Jeffries
<ne**@andyjeffr ies.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*******@attg lobal.net> wrote:
no@emails.th x 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*******@attg lobal.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*******@attg lobal.net> wrote:

no@emails.t hx 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*******@attgl obal.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="liveProgres s"></div>

2. In your PHP code, add this function:
function setProgress($x) {
echo "<script type=\"text/javascript\">"
. "document.getEl ementById('live Progress').inne rHTML = '$x';"
. "</script>";
flush();
}

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

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><ti tle>Progress Test</title></head><body>
<div id="liveProgres s"></div>
<hr /><?php
function setProgress($x) {
echo "<script type=\"text/javascript\">"
. "document.getEl ementById('live Progress').inne rHTML = '$x';"
. "</script>";
flush();
}
$max = 7;
for ($i = 0; $i < $max; $i ++) {
echo 'Loop #' . ($i + 1) . ' of ' . $max . '<br />';
setProgress('Lo ading...' . round(($i / $max) * 100) . '%');
sleep(1);
}
setProgress('Fi nished!!');
?>
</body></html>

Jun 23 '06 #10

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

Similar topics

5
2139
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 the DataSet. The ReadXML is a rather lengthy operation with >5mb xml files (I am reading in the schema and ignoreschema on read). This has presented several problems 1) What kind of progress bar can I show during load since I can't increment...
1
1796
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 indicators until I use the ALT key)... Is there a way to programatically turn on/off keyboard navigation indicators for my app during runtime... Thanks, STefan
4
5739
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 file is finished uploading but am not sure how to do it while file is uploading. Some sample code would be welcomed with open arms. Thank You.
3
2874
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 that might take 5-8 seconds. I tried to putting the gif in a sepearate page and referencing it using iframe thinking that if the gif is on another page & calling it from my main page, it would not be affected by my submittals and continue to...
6
2142
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 that is located on multiple pages. Therefore I need to embed a code segment to be executed when a specific button is pressed to display the "Please Wait" without having to wait for the postback to finish. I am looking to do this in a client...
6
6427
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 function The code that i have been given in an example is: 'this is added to the tick event for the timer
1
4122
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 framework 1.1). The application implements a Progress Bar webcontrol, that pops up in a window, using the HttpHandler interface, on the event of a button click. The handler's process request routine reads the status of the progress by querying the...
15
3558
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 final display of the data from the database. I was thinking of manually opening a second thread in the Render method, but nothing is displayed before the render method exits anyway. Anyone know of a good way to do this? I have been working on this...
14
2793
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 we click on the Log-in button, it should display a progress indicator image which needs to be spinning round till the page gets navigated to the next page if the username and password are correct. Here I am posting my code: <div...
0
9762
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10782
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10384
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9531
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7094
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5761
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3201
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.