S
S
Sebastian Pereira2014-02-21 10:55:17
PHP
Sebastian Pereira, 2014-02-21 10:55:17

PHP progressbar: how to make it work?

Hello. There is a script which is executed long enough.

I want to display the percentage of script completion in a beautiful progress bar.
Using mysql_num_rows($answsql) I get the total value. But here's how to tie it all, but to make it work, I did not find it.

Tell me or share an example. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaly Zheltyakov, 2014-02-21
@VitaZheltyakov

In short, run the script. When calculating $i, save either to the session or to a file (we also save the final result). At this time, on the client, you start sending periodic ajax requests to another script to read this $i. Upon completion, we make a request for the final result.
But my advice to you - do not do this nonsense. Better hang a sign "There is a calculation, please wait. There are no errors"

V
Viktor Koreysha, 2014-02-21
@Iktash

As a simplified version, it is rough to calculate the time and make a pseudo progressbar.

D
DeFacto, 2014-02-22
@DeFacto

If there are a lot of records, then insert them in parts.
Send a request ajax.php?start=0
wait for a response (in response you get something like 100/10000) - send ajax.php?start=100
and so on ..
You can increase the progress bar by 1% (or 10% by each step) )
by selecting the desired step size.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question