solarisuser Posted October 4, 2007 Share Posted October 4, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/71789-solved-is-it-possible-to-use-ob_start-to-do-what-i-want/ Share on other sites More sharing options...
haaglin Posted October 4, 2007 Share Posted October 4, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/71789-solved-is-it-possible-to-use-ob_start-to-do-what-i-want/#findComment-361540 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.