What if you buffer the rest of the output by PHP while only displaying a ' please wait' message? Something like this:
<?
flush();
echo("<p>Please wait a while...</p>");
$output = "";
while (something) {
$output .= doStuff();
}
echo $output;
?>
This way you only see the wait message and the complete output is written at once when it's finished. ...or?