Jump to content

[SOLVED] is it possible to use ob_start() to do what I want?


solarisuser

Recommended Posts

Hi All,

 

I have a bit of code that is parsed when user clicks on a submit button using POST.

 

It looks something like this

<img src=show_loading.jpg>
$sql = mysql_query(SELECT .....);
while($row = mysql_fetch_array($sql))
{.... }
etc

 

The code takes up to 10 seconds to run, and then uses header() to redirect the user to another page.

 

The problem is, php parses through all the mysql queries, then once its completed, shows the loading picture for a second, then redirects using header().  I am wondering if I can use ob_start() to show the loading picture, then have the mysql code be parsed, and header() will redirect to another page when completed.

 

I've played around with various iterations of ob_start() in different places but it doesn't have the effect I'm looking for.

 

Anyone have any ideas?  Thanks

header() redirecting can't be used after any output to the browser.

as for the loading icon, maybe flush() is what you are looking for:

 

<img src=show_loading.jpg>

flush();
sleep(1);

$sql = mysql_query(SELECT .....);
while($row = mysql_fetch_array($sql))
{.... }

 

btw. Flush can not be inside "unfinished" tables..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.