0

I have a PHP website for listing all the education centers. My webpage is like this enter image description here

my webpage code is like this

html code for header
.......................
php and mysql code for retrieve district
............................
php and mysql code for retrieve locality
.................................
php and mysql code for retrieve listings
...........................
php and mysql code for retrieve more links
...............
html code ends...

My problem is that, on page running first district prints.. after certain time( approx 10sec) locality prints.. after certain time(approx 20sec) listings print... after certain time (30 sec) more links print...

I want to display all results at once, with no lag between each part.

Is there a way of getting all the parts to display at once?

Raad
  • 4,540
  • 2
  • 24
  • 41
Nidhi
  • 153
  • 2
  • 12
  • *"my webpage code is like this"* - There's `"code"`? – Funk Forty Niner Feb 04 '14 at 16:56
  • 99% of the time a screenshot is completely pointless and just gets in the way. **Source code** is the most important thing to be posting so people can help you with your problem. – tadman Feb 04 '14 at 16:58
  • *"Is there a way of getting all the parts to display at once?"* - Yes, it's called [`include()`](http://www.php.net/manual/en/function.include.php) – Funk Forty Niner Feb 04 '14 at 17:01
  • It sounds like your queries are taking a long time to run. 20 seconds is a long time for a properly optimized query - I'd suggest checking the performance and see if you can speed it up by adding indices. – andrewsi Feb 05 '14 at 00:36

1 Answers1

0

You could use PHP output buffering - see What is output buffering?

The disadvantage is that if your queries are slow, the user ends up waiting a long time before they see any output - not a good User Experience.

A better way would be to have the page load with placeholder content, and use AJAX to replace the placeholder content with real content.

Also, 20 or 30 seconds for content to load is far to long. Try looking at your queries again, with a view to optimising/improving their performance.

Community
  • 1
  • 1
Raad
  • 4,540
  • 2
  • 24
  • 41