A Way to Flush to a browser and continue with the query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SpecialK
Forum Commoner
Posts: 96
Joined: Mon Sep 18, 2006 3:49 pm

A Way to Flush to a browser and continue with the query

Post by SpecialK »

I have a processing image for a large query and now that I know a little more theory behind PHP, I am ready to ask for help regarding the question.

The file that does all the processing and query calling is from an include. Currently I am trying along these lines from things I have read:

index.php

Code: Select all

include "header.php"
include "content.php"
include "footer.php
content.php

Code: Select all

ob_start();
//output processing image
echo str_pad('',4096)."\n";
ob_flush();
flush();
ob_end_flush();

//call to the query on a remote machine
What I need is a way to ensure that this image is displayed before the query in a huge table is displayed and then plan on using Javascript to hide the image from the user.

Is there something I am doing wrong that this won't output properly? I can see most of the header is output to the browser, but never can get the processing image displayed. The lucky thing is I am only required to have this working for IE6/7 and FF2 so buffer output from the browser is less of an issue as long as the processing image is displayed.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Many servers maintain their own buffer of output to send to the browser. flush() and the like simply shift the buffering responsibility from PHP to the web server. So you may need to look further there or choose a different way.

Multi-part pages and Post-Redirect-Get comes to mind.
Post Reply