You are here: Re: [PHP] sleep function « PHP « IT news, forums, messages
Re: [PHP] sleep function

Posted by Philip Hallstrom on 05/13/05 00:17

> Hi,
>
> I want to create a script that displays all names from a database once per second.
> A part of the script look like this.
>
> for ($i=0; $i<$total_names; $i++)
> {
> echo "name<br>";
> sleep (1);
> }
>
> The scipt works fine but it displays all names at once. I want to display the first name, then refresh the browser and display the first name and the second, then the first name, the second and the third ....and so on.
> Can someone please tell me how can i do this?

Right before your sleep(1) function add:

flush();

This should do it. Depends on how your webserver buffers things and if
there's any proxy servers, etc. in the way.

-philip

 

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

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