Here is what I have done before, but it is not 100% perfect in all cases.
lets say you have:
RUN QUERY PARSE DATA
for(whatever){
for(whatever2){
query();
}
?>
<SCRIPT>
document.divname.width=<? echo $newpixwidth; ?>;
<?
flush();
flush();
}
?>
and then a <div> 's laid out like a progress bar
so as it runs, it flushes output, and the width of 1 div inside another moves. The end effect looks pretty good most of the time.
If your just talking about 1 query that takes ages, there isn't really a good way to do it, unless you hand the process off to a daemon and just have a fake progress bar that is timed for 1 minute.