hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Progress bar in PHP
Reply

Forum Jump

Progress bar in PHP

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-25-2002, 10:21 AM
combs combs is offline
Junior Guru
 
Join Date: Aug 2002
Location: Plymouth
Posts: 212
Lightbulb

Progress bar in PHP


I need a script for showing progress bar in PHP while I process my database records. Any ideas...?

PC configuration: windows xp, apache and php 4.0.6 and php is not as a cgi to apache but a module..



Sponsored Links
  #2  
Old 08-25-2002, 11:33 AM
Omair Haroon Omair Haroon is offline
Web Hosting Evangelist
 
Join Date: Feb 2001
Location: Pakistan Baby!
Posts: 455
Well, I remember there was an article on hotscripts.com. Give me a minute and I would post the article URL over here.

__________________
36Host.com - reliable & affordable web hosting
* Providing Affordable Small Business Web Hosting since 2003! *


  #3  
Old 08-25-2002, 11:40 AM
Omair Haroon Omair Haroon is offline
Web Hosting Evangelist
 
Join Date: Feb 2001
Location: Pakistan Baby!
Posts: 455
Here it is:
http://www.hotscripts.com/Detailed/13962.html

Though in Javascript, but you can use it in conjunction with PHP with a little bit of creativity. Give me a shout if you need help!

__________________
36Host.com - reliable & affordable web hosting
* Providing Affordable Small Business Web Hosting since 2003! *


Sponsored Links
  #4  
Old 08-25-2002, 11:42 AM
Omair Haroon Omair Haroon is offline
Web Hosting Evangelist
 
Join Date: Feb 2001
Location: Pakistan Baby!
Posts: 455
Here is yet another URL with more results:

http://www.google.com/search?q=progr...&start=10&sa=N


--Omair

__________________
36Host.com - reliable & affordable web hosting
* Providing Affordable Small Business Web Hosting since 2003! *


  #5  
Old 08-25-2002, 11:51 AM
interactive interactive is offline
Web Hosting Master
 
Join Date: Aug 2002
Location: Chandler, Arizona
Posts: 2,564
since php is server side its extremly hard to do it. but you could try.

__________________
-Robert Norton
www.SophMedia.com

  #6  
Old 08-25-2002, 12:04 PM
Omair Haroon Omair Haroon is offline
Web Hosting Evangelist
 
Join Date: Feb 2001
Location: Pakistan Baby!
Posts: 455
Actually not that hard

__________________
36Host.com - reliable & affordable web hosting
* Providing Affordable Small Business Web Hosting since 2003! *


  #7  
Old 08-25-2002, 05:31 PM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
Well... Pretty much any progress bar that would be displayed would simply be faking the progress that is taking place.

PHP is a server side scripting language...

Follow the progress of a PHP script

Page Request to server
Server Parses Page
-- Calls DB if needed in script
Page is outputted to browser

There is no page->Server interaction in a PHP script.

If I have a page that would do maybe 30,000 alterations to a DB that page would only display to the browser after it's been completely parsed by the server. So the page would only display after the 30,000 DB calls have been completed. I can't picture in my head a script that alters the browser content at every X DB manipulations.

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

  #8  
Old 08-25-2002, 05:41 PM
The Prohacker The Prohacker is offline
iNET Interactive
 
Join Date: May 2001
Location: Dayton, Ohio
Posts: 4,894
Quote:
Originally posted by Studio64
If I have a page that would do maybe 30,000 alterations to a DB that page would only display to the browser after it's been completely parsed by the server. So the page would only display after the 30,000 DB calls have been completed. I can't picture in my head a script that alters the browser content at every X DB manipulations.

Not really, you can have the page output an update during the mysql updates...


db initilze
progress start
db insert
update progress bar 1%
db insert
update progressbar 3%
dbinsert
etc..


So... just echo out the update to browser and do the next db insert...

__________________
-Mat

  #9  
Old 08-25-2002, 06:16 PM
The Prohacker The Prohacker is offline
iNET Interactive
 
Join Date: May 2001
Location: Dayton, Ohio
Posts: 4,894
For a status bar that would allow you to update like I said above...

http://webfx.eae.net/dhtml/statusbar/statusbar.html

__________________
-Mat

  #10  
Old 08-25-2002, 09:34 PM
Ahmad Ahmad is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Kuwait
Posts: 679
Quote:
Originally posted by The Prohacker



Not really, you can have the page output an update during the mysql updates...


db initilze
progress start
db insert
update progress bar 1%
db insert
update progressbar 3%
dbinsert
etc..


So... just echo out the update to browser and do the next db insert...

There is actually a problem with this solution ..

PHP by default buffers the output of the script until the buffer is full before sending it to the client, to achieve maximum network utilization. This buffering is also done at the Apache level, and the OS level. You can probably bypass all these buffers by calling flush(); ..

However, there are still other buffers you don't have control over, like buffering at a proxy server.

All-in-all, this is a nice method, but unreliable most of the time.

An alternative solution would be refershing the page for each chunk of the updates. Say you have 33,000 records to update, so what you do is make 1000 updates with every call, so you start by the first 1000, stop execution, return an HTML page that will display a progress bar and redirect to user to a URL that will cause the update of the next 1000 records, until you finish all the processing.

You can also use a combination of JavaScript and frames to achieve a nice looking progress bar.

edit: check the man page for flush(), there is nice information about this issue. Also in the comments, somebody talks particularly about how he made a progress bar:

http://www.php.net/manual/en/function.flush.php

__________________
Ahmad Alhashemi
PHP, Apache, C, Python, Perl, SQL
18 related BrainBench certificates


Last edited by Ahmad; 08-25-2002 at 09:43 PM.
  #11  
Old 08-26-2002, 03:16 AM
archie2 archie2 is offline
Junior Guru
 
Join Date: Aug 2002
Location: deville
Posts: 214
*

That was a wonderful link provided by Ahmed. I will also try. Thank you

  #12  
Old 08-27-2002, 01:19 PM
combs combs is offline
Junior Guru
 
Join Date: Aug 2002
Location: Plymouth
Posts: 212
Thank you all for your feedback.
I have not made it yet but I am in the process of making it. It was really a great help.

Reply

Related posts from TheWhir.com
Title Type Date Posted


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?