Jump to content

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


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..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.