title: Trying to display a Loading screen in PHP, but doesn't display until after script is executed?
body: <p>I am trying to display a loading message with an loading bar animation so people know the script is working away.</p>
  
  <p>However even though the HTML is at the top of my PHP script , it only gets displayed once the script is fully loaded.</p>
  
  <p>The script takes about 40 seconds to complete because it Generates a PDF, Inserts Data into a DB then sends a MIME email to an external MX (takes the longest part).</p>
  
  <p>Here is the HTML that displays the loading message:</p>
  
  <pre><code>        &lt;div class="grid_16"&gt;
                  &lt;fieldset&gt;
  
                      &lt;h2&gt;
                          Processing &lt;img src="img/loading.gif" alt="loading animation"&gt;
                      &lt;/h2&gt;
  
                  &lt;/fieldset&gt;
      &lt;/div&gt;
  &lt;?php
  
  //rest of php page
  </code></pre>
  
  <p>Any idea how I display this out to the user so they don't get impatient and start hitting F5 etc.</p>
  
  <p>Thanks</p>
  
  <p>Merry Christmas!</p>