[SOLVED] showing progression bar

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
faheemhameed
Forum Newbie
Posts: 5
Joined: Thu Oct 23, 2003 1:35 am

showing progression bar

Post by faheemhameed »

Hi there,

I wanted to send a few thousands of email to my list of contacts using php. How can I show a progression bar in the browser? I want to display approximate time to finish, how many emails to send etc.

Please shed some lights

Thanks
Hameed
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh... use refreshes while you process. You'll likely have to batch the mailings, because a lot of servers have a limit they allow someone to send in a given period of time.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

general idea is to echo js which would advance the progress bar:

Code: Select all

set_time_limit(0);
echo <<<EOF
<script language='Javascript'>
  function advance() {
      pg = document.getElementById('pg');
      pg.style.width = (parseInt(pg.style.width)+1)+'px';
  }
</script>
<div style='width:0px; height:10px; background:blue' id='pg'>&nbsp;</div>
EOF;

for($i = 0; $i<100; $i++) {
   echo '<script language="Javascript">advance();</script>';
   flush();
   sleep(30);
}
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

bluescreen

Post by djot »

-

Hi,

I never had a bluescreen with WinXP since I tried this progress bar above.

I did change the for limit to $i<10000 and sleep(0.5).

After that my PC hang up with bluescreen :)

djot

PS: anyway I should have used usleep();
-
Last edited by djot on Sat Jul 03, 2004 11:10 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]sleep[/php_man] wrote:void sleep ( int seconds)
notice how it takes an integer, that may have caused the crash.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

another one

Post by djot »

-

Hi

This one is nice and easy also:
http://www.phpclasses.org/browse/package/1222.html

djot

-
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<?php
usleep(500000);
?>
this will sleep for half a sec
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

dont know why it crashes

Post by djot »

-

The php was running on a linux server. But my pC crashed :)
so perhaps it was the browser.

first attemp was $i<100 and sleep(0.5), that did not crash. But $i<10000 and sleep(0.5) did.

Anyway, i just wanted to point out that I had my first blue screen.
(and i did add a PS in my previous post also)

djot

-
faheemhameed
Forum Newbie
Posts: 5
Joined: Thu Oct 23, 2003 1:35 am

Post by faheemhameed »

Thank you all for your help.

I am using the progression bar class from phpclasses

Works fine.

Thanks
Hameed
Post Reply