EmperorJazzy Posted March 9, 2012 Share Posted March 9, 2012 So I have 2 queries, that has the potential to return alot of data, foreach loops running. The first shows each group heading, and the foreach nested is calling another query specific to the group heading. The result currently is a lengthy delay in results showing. (Now this may/may not be the most ideal code practise in this instance however... short term solution discussion please). For Each State Read Each States Details from DB For Each State Listing Display Details Next Next Is there a command or other where I can say, Display HTML page as it stands while it continues to process the FOREACH loops? EG: For Each State Read Each States Details from DB For Each State Listing Display Details REFRESH HTML DISPLAYED Next Next Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/ Share on other sites More sharing options...
kicken Posted March 9, 2012 Share Posted March 9, 2012 Now this may/may not be the most ideal code practise in this instance however... short term solution discussion please Ideally you would use a single query and a JOIN to get the data you need. You would do your headings by tracking the value of the field used for the header and only output the code for a header if it changes. Switching to this single query method would likely result in a considerable speed-increase of your page. Executing multiple select queries in a loop as you described is one of the biggest performance no-nos you can do. Is there a command or other where I can say, Display HTML page as it stands while it continues to process the FOREACH loops? You can use ob_flush and flush to clear out PHP's buffers and send the data. Whether that makes it all the way to the browser and gets rendered is a whole different story that you cannot control though. There may be other buffers such as a proxy server or the browsers internal render buffer. Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/#findComment-1325459 Share on other sites More sharing options...
EmperorJazzy Posted March 14, 2012 Author Share Posted March 14, 2012 REsolved. Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/#findComment-1327186 Share on other sites More sharing options...
trq Posted March 14, 2012 Share Posted March 14, 2012 REsolved. We have a button for that. Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/#findComment-1327187 Share on other sites More sharing options...
EmperorJazzy Posted March 14, 2012 Author Share Posted March 14, 2012 REsolved. We have a button for that. Where? I went looking for it and couldn't find it? Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/#findComment-1327196 Share on other sites More sharing options...
trq Posted March 14, 2012 Share Posted March 14, 2012 Toward the bottom of your post. Link to comment https://forums.phpfreaks.com/topic/258575-showing-results-while-loop-continues/#findComment-1327198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.