Re: Progress bar?
| From: | Murph | Date: | Fri, 08 Dec 2000 23:47:42 +0000 |
| Subject: | Re: Progress bar? | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29427@lists.php.net to get a copy of this message | ||
You could probably do an SQL LIMIT type of thing to break it into manageable
chunks.
Thanks, guys!
Murph, the original poster
> If you use the theory you specify below with the theory from my previous
> email, I'm convinced that we have a solution.
>
> Basically my previous message stated that you should split your single
query
> into multiple queries, when each query finishes you can send a response to
> the browser telling it to increment the status bar.
>
> If you use the Microsoft theory for status bars they always get to 100%
and
> then wait another 30 seconds before the process finishes anyway, so I
> wouldn't worry too much about accuracy :-) ho-ho-ho
>
> Andy.
> www.databasewatch.com
>
> ----- Original Message -----
> From: "Jason Lavigne" <jlavigne@stonecroft.net>
> To: "Andy Woolley" <andy@milonic.com>
> Cc: <php-general@lists.php.net>
> Sent: Saturday, December 09, 2000 3:08 AM
> Subject: Re: [PHP] Progress bar?
>
>
> > You could use it for anything as long as the bar knows what the end
number
> > will be and when you send an update the number must be less that or
equal
> > that the end.
> >
> > If you wanted to you could send 100 and your starting number then break
it
> > done (in your code) like this
> > 0% - 20% means the getting data.
> > 21% - 40% means sorting data, also send a text message for the user
> > "Sorting...Please wait."
> > 41% - 60% means comparing data, also send a text message for the user
> > "Comparing..Please wait."
> > 61% - 80% means cleaning data, also send a text message for the user
> > "Cleaning data...Please wait."
> > 81% - 100% means writing back the data, also send a text message for the
> > user "Writing...Please wait."
> >
> > So the user would see this.
> > 0% Please wait, initializing. (In you code you are doing your select)
> > then the bar jumps to 20% and then increments to 21%, 22% .... to 40%
> while
> > the sort happens etc... for the remainder 60% while your code does it's
> job.
> >
> > Now about the network traffic, on an Intranet this is not an issue
because
> > all that is being send is a number surrounded by JavaScript like this.
> > "<script>DoBarUpdate(45);</script>"
> >
> > This is exactly how all status bars that display the correct processing
> > percentage works, easy isn't it :)
> >
> > Jay
> >
> >
> > ----- Original Message -----
> > From: "Andy Woolley" <andy@milonic.com>
> > To: <php-general@lists.php.net>
> > Sent: Friday, December 08, 2000 9:42 AM
> > Subject: Re: [PHP] Progress bar?
> >
> >
> > > Jay,
> > >
> > > I take it you are looking at a function to display a status bar mostly
> for
> > > long queries.
> > >
> > > How about doing 5 queries to return the same results and then
> incrementing
> > > the status by 5 each time one of the queries has been completed.
> > >
> > > Like this
> > > 1. Run a query to return the total number of records: $totalrecords.
> > > 2. Divide this value ($totalrecords) by 5: $recorddivision
> > > 3. Set a starting point value: $starter
> > > 4. Set records variable: $records = $recorddivision
> > > 5. Iterate through a Loop (5 Times)
> > > 6. Set query 1 to be :SELECT * FROM ..... LIMIT $starter, $records
> > > 7. Increment loop adding $recorddivision value to $starter and
$records
> > > 8. On each iteration send a response to the browser to increment the
> > status
> > > bar.
> > >
> > > This would add network traffic and page load times but could work as
> long
> > as
> > > your query isn't too complex.
> > >
> > > Let me know what you think.
> > >
> > > Andy
> > > www.databasewatch.com
> > >
> > >
> > > ----- Original Message -----
> > > From: "Jason Lavigne" <jlavigne@stonecroft.net>
> > > To: "Miles Thompson" <milesthompson@sprint.ca>;
<murph@murphatnight.com>
> > > Cc: <php-general@lists.php.net>
> > > Sent: Saturday, December 09, 2000 2:01 AM
> > > Subject: Re: [PHP] Progress bar?
> > >
> > >
> > > > This bar would not get that until after the query was done, but if
> there
> > > was
> > > > processing, comparing data from query with user input, then at that
> time
> > > the
> > > > status bar would "kick" in and give feed back. Like this:
> > > >
> > > > 1) Query DB
> > > > 2) Return number of rows to browser
> > > > 3) Processing a row from result
> > > > 4) Update the record count to the browser
> > > > 5) Go to 3 if not done
> > > >
> > > > This would at least tell the user about how many records are left to
> > > > process.
> > > >
> > > > On most queries, this bar would be up for a second or two, but for
> heavy
> > > > data processing ( checking inventory against what ever, 100,000+
> > records )
> > > > it could be useful.
> > > >
> > > > Yes the JavaScript end could be mean but in the PHPChat Example
> > > > (http://www.phpwizard.com) they did a good job at handling it.
> > > >
> > > > The DHTML or Flash is only used to display a message and a % with a
> bar.
> > > > Nothing more.
> > > >
> > > > Now the more I think about it, this could be useful, a couple of
> > > functions,
> > > >
> > > > StartProgressBar() - Would open the streaming window with DHTML.
> Default
> > > > message "Please wait, initializing."
> > > > SendProgressStart() - Would be the total num, ie... num of records,
> 100
> > or
> > > > what ever number you wanted to mean "this is the end number".
> > > > SendProgressMessage() - Would send a text message to the window for
> the
> > > user
> > > > "Updating your file.....Please wait...."
> > > > SendProgress() - This would be the update number, this would make
the
> > > "bar"
> > > > move and the % number update.
> > > >
> > > > By default, when SendProgress() reaches 100%, the DHTML and/or Flash
> > would
> > > > shut itself down and display the output from the system.
> > > >
> > > > I never said nor implied that this would be for a beginner to
create,
> > this
> > > > would be for an advanced programmer to tackle.
> > > >
> > > > I just do not like people saying "That is not possible", it is
ALWAYS
> > > > possible, just look at it in a different way :)
> > > >
> > > > Jay
> > > >
> > > > ----- Original Message -----
> > > > From: "Miles Thompson" <milesthompson@sprint.ca>
> > > > To: "Jason Lavigne" <jlavigne@stonecroft.net>
> > > > Cc: <murph@murphatnight.com>; <php-general@lists.php.net>
> > > > Sent: Friday, December 08, 2000 8:26 AM
> > > > Subject: Re: [PHP] Progress bar?
> > > >
> > > >
> > > > > Jason,
> > > > >
> > > > > Very impressive - but what SQL engines provide a count of records
as
> > > they
> > > > > process? Or is that a part of the MySQL / PostgreSQL docs I
haven't
> > > > uncovered
> > > > > yet?
> > > > >
> > > > > I do believe, with all the Javascript and DHTML it would be an
> ongoing
> > > > > maintenance headache.
> > > > >
> > > > > I'm also curious about the original poster's query, which
apparently
> > > takes
> > > > so
> > > > > long to run. Full join on a big table?
> > > > >
> > > > > Miles
> > > > >
> > > > > Jason Lavigne wrote:
> > > > >
> > > > > > If you were to use a streaming HTML window from PHP ( as seen in
> > > PHPChat
> > > > on
> > > > > > http://www.phpwizard.com ) you can
> > > > > > keep sending data to the
> browser
> > > > without
> > > > > > reposting ( read about flush() ) to the server. So if you did
this
> > you
> > > > could
> > > > > > do the following in PHP:
> > > > > >
> > > > > > Do select from SQL and return Num of rows (use a function that
> > counts
> > > > the
> > > > > > total number of records from the select) and send that to the
> > browser.
> > > > > > As you process each record you could send back to the browser
that
> > you
> > > > > > processed X records. (I would send this update after 10 records
or
> > add
> > > > code
> > > > > > that after each % that was done I send back that number)
> > > > > > At this time the browser has the total number of records and is
> > > > receiving
> > > > > > the record number that was processed (10 out of 100 etc...)
> > > > > > Then using JavaScript you could feed those values in to DHTML or
> > Flash
> > > > to
> > > > > > graphically do a status bar.
> > > > > >
> > > > > > Is there another solution? I am sure there is, but it is not
> > > impossible.
> > > > > >
> > > > > > Let me know if you do do this, I would be interested is seeing
in
> > > > working :)
> > > > > >
> > > > > > Jay
> > > > > >
> > > > > > ----- Original Message -----
> > > > > > From: "Miles Thompson" <milesthompson@sprint.ca>
> > > > > > To: "Murph" <murph@murphatnight.com>; "PHP
> > > > > > General List"
> > > > > > <php-general@lists.php.net>
> > > > > > Sent: Friday, December 08, 2000 7:25 AM
> > > > > > Subject: Re: [PHP] Progress bar?
> > > > > >
> > > > > > > If you did one you'd have to fake it. Think about it, the
> > > > > > > web
is
> > > > stateless
> > > > > > environment, no channel is opened and maintained to the back
end,
> > and
> > > > SQL
> > > > > > queries are essentially the same. If a progress bar
> > > > > > > displays while a SQL query executes, it's provided by the
> database
> > > > vendor.
> > > > > > >
> > > > > > > If you did have feedback from the SQL engine you would need to
> > keep
> > > > firing
> > > > > > new pages to the browser.
> > > > > > >
> > > > > > > Regards - Miles Thompson
> > > > > > >
> > > > > > > Murph wrote:
> > > > > > >
> > > > > > > > Hi!
> > > > > > > >
> > > > > > > > Has anyone invented a progress bar that displays on a web
page
> > to
> > > > > > entertain the viewer while they wait for a query to finish? I'd
be
> > > > > > interested in getting a pointer to a snippet of code if you have
> it.
> > > > > > > >
> > > > > > > > Yours,
> > > > > > > > Murph
> > > > > > > >
> > > > > > > > www.murphatnight.com
> > > > > > > >
> > __________________________________________________________________
> > > > > > > > Brian Murphy - 193A Lowell St., Apt. 24 - Methuen, MA
01844 -
> > > (978)
> > > > > > 725-6654
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > PHP General Mailing List (http://www.php.net/)
> > > > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > > > > > For additional commands, e-mail:
php-general-help@lists.php.net
> > > > > > > To contact the list administrators, e-mail:
> > > > php-list-admin@lists.php.net
> > > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > > For additional commands, e-mail: php-general-help@lists.php.net
> > > > To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > > For additional commands, e-mail: php-general-help@lists.php.net
> > > To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net