|
Posted by Matthew White on 08/04/07 21:18
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.twjxk0d2qnv3q9@metallium...
> On Sat, 04 Aug 2007 21:57:04 +0200, Mad Hatter <colin@class31.co.uk>
> wrote:
>
>> Hi
>>
>> I've written a little routine for backing up a large(ish) mysql database.
>> Basically what I want it to do is echo to the screen 'backing up table
>> 1',
>> 'backing up table 2' etc as it's going along. The routine runs along the
>> following lines
>>
>> while ($i < $tables) {
>> echo "Backing up table $i";
>>
>> opens a file here
>> it reads the table from the database here
>> writes it to a file here
>> closes file
>>
>> }
>>
>> I expected after each read/write it would output "Backing up table x" but
>> it reads/writes them all and then echoes all the backing up text in one
>> go.
>> What am I doing wrong?
>
> There's a caching/buffer mechanism somewhere. Try to use flush() after
> each echo, maybe it helps, maybe it doesn't: it can depend on server &
> browser. See the description & user contributed notes in the manual for
> flush().
> --
> Rik Wasmus
No, the problem is your language. PHP creates HTML pages. It doesn't
modify them on-the-fly. A page that says:
<?php
while ($i < $tables) {
echo "Backing up table $i";
?>
will output an HTML file:
<body>
Backing up table 1Backing up table 2
</body>
This HTML file is then downloaded by the browser. If you want
interactivity, try using JavaScript instead.
Matt
Navigation:
[Reply to this message]
|