You are here: Re: Progress indicators on a page...? « All PHP « IT news, forums, messages
Re: Progress indicators on a page...?

Posted by infolock on 06/20/06 15:14

Not really. The best thing to do is use Ajax to just inform the user
that an operation is happening, but actually displaying a progress bar
that shows the actual percentage of the insert is gonna be nearly
impossible.

However, there is a way... and it's by no means the best way.

You could always write a loop inside of a loop that queries the table.
Each iteration would send a request back to ajax telling it to
increment the % or number by 1. I wrote this already once, and it
turned out to be about 150% slower than just running the script as
normal. So, I'd just give the user the note.

Now, if you are as bullheaded as I am when someone tells me it won't
work and you want to just try it out for yourself, go for it. Just
don't say I didn't tell you so ;)

Example :

html :

<submit button>Onclick = ajax call => PHP script to isnert records

<div tag containing the progress bar = 0%>

<javascript function = div tag + 1% to progress>

<javascript fucntion = tell php which iteration we are wanting to
update


php :

$which_iteration = $_GET['iteration'];
$sql;
$total_left = ( $which_iteration / count($my_list_of_records) )*
100;
echo $total_left;





no@emails.thx wrote:
> Hi
>
> I have a PHP script that updates a very large table and in the code I
> echo some text to show the progress of the update but the text only
> appears when the page has finished displaying.
>
> Is there any way (through html headers?) to force the page to update
> in real time, while the PHP script is still executing?
>
> I have seen similar thngs on webmin pages when it is downloading
> updates and it is nothing fancy (graphics etc) - just text.
>
> Thanks
> Chris R.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация