Re: [PHP-DB] help in implementing a progress bar

[email protected] (Philip Thompson)
Newsgroups php.db
Message-ID <[email protected]>
On Jan 7, 2010, at 2:36 PM, Vinay Kannan wrote:

> Hello,
> 
> Theres this project that I am working on, and a specific module does take
> few secs to process, I am thinking it would be cool to be showing a progress
> bar(some kind on a .gif image) while the script runs, does any one have an
> idea how to implement this?
> 
> Thanks,
> Vinay K

This isn't really database related, but ok...

<?php
// Progress.php
class Progress {
    public function start () {
        echo file_get_contents ('progress.html');
        flush ();
    }
    public function end ($url) {
        $text  = "<script type=\"text/javascript\">";
        $text .= "window.location = '$url';";
        $text .= "</script>";
        
        echo $text;
        flush ();
    }
}
?>

<?php
// process.php - process the stuff
$progress = new Progress();
$progress->start();
// ... Do your processing here ...
$progress->end('nextpage.php');
?>

In the progress.html file, it would just be an html page that has an animated gif (and whatever else you want on it). Hope this helps.

~Philip
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.