0

Is there a way to tell a page to start showing the page data while a php function is executing? have a page where I show a year calendar with descriptions for each day of the year. The page takes a long time to run. I am looking into ways to optimize the speed. However, I had a general question about page loading. I have seen web pages that start filling out a scrolling area as the page data becomes available. My page only loads when the PHP script is done.

Here is the code structure.

  1. Build page header.
  2. Call PHP script to fill out page content.
  3. Print echo statement to write out calendar table.
  4. Loop through months of the year.
  5. Call date functions to show each day of the month.
  6. Call php function on external domain to echo description for each day of the month as table row.
  7. Build page footer.
  8. Scroll-top to current day.

I'd like to be able to show the rows for each day of the month as they are generated. Is this something that can be done when calling a PHP function? Can this only be done with Javascript? The script that writes the description for each day, as mentioned earlier, is a PHP script from an external domain.

For each row in the year calendar I call three PHP scripts as show here.

$showfeast = file_get_contents('http://feed.evangelizo.org/reader.php?date=20110622&type=feast&lang=AM');
$showliturt = file_get_contents('http://feed.evangelizo.org/reader.php?date=20110622&type=liturgic_t&lang=AM');
$showsaints = file_get_contents('http://feed.evangelizo.org/reader.php?date=20110622&type=saint&lang=AM');

The date string sent to that script is calculated by calling the PHP date functions mktime and date, usually like this for each day.

   $curTime = mktime( 0, 0, 0, $thisM, $i-$sOffset +1, $thisY );
   $curDate = date("Y-m-d", $curTime);

It wouldn't be helpful to show the entire code here. I am mostly looking for advice for the best way to design the code to achieve the goals:

  1. Show each row for the given day of the calendar as it is generated.
  2. Find the best way to call the external domain PHP script to meet goal 1.

It is possible for me to completely redesign the code. The only constraint is to call the three PHP scripts shown earlier for each day of the year.

Thanks for your advice.

user823527
  • 3,644
  • 17
  • 66
  • 110

1 Answers1

0

Have JavaScript load it via AJAX call when page is done loading.

Aleksey Korzun
  • 680
  • 4
  • 7