Display image before for loop execution
<p>Following is my script in which i am converting xls to csv . The problem i am facing no matter what is mentioned before the piece of code of the for loop, it  runs first.Kindly let me know how can i display the image from the following script first and then run the loop script:</p>

<pre><code>&lt;body&gt;

asdjasldjasdlj // Even this text gets load after execution of for loop
&lt;!-- Progress information --&gt;
&lt;div id="information" style="width"&gt;&lt;img src="images/L.gif" /&gt;&lt;/div&gt;

&lt;?php 
     require_once 'lib/excel_reader2.php';
    $excel = new Spreadsheet_Excel_Reader();
    $excel-&gt;setOutputEncoding('UTF-16');
    $excel-&gt;read('Student2.xls');
    $x=1;
    $sep = ",";

   $nbSheets = count($excel-&gt;sheets);
  echo $x." -  ".$nbSheets;

  $total = $nbSheets;

for($i = 0; $i &lt; $nbSheets; $i++) {
           ob_start();
    while($x&lt;=$excel-&gt;sheets[$i]['numRows']) {
        $y=1;
        $row="";
        while($y&lt;=$excel-&gt;sheets[$i]['numCols']) {
            $cell = isset($excel-&gt;sheets[$i]['cells'][$x][$y]) ? $excel-&gt;sheets[$i]['cells'][$x][$y] : '';
            $row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\"";
            $y++;
        } 
        echo $row."\n"; 
        $x++;
    }
    $x = 1; $y = 1;
    $fp = fopen("data.csv",'a');
    fwrite($fp,ob_get_contents());
    fclose($fp);
    ob_end_clean();

}

echo "CSV file created successfully";
// Tell user that the process is completed
echo '&lt;script language="javascript"&gt;document.getElementById("information").innerHTML="Process completed"&lt;/script&gt;';

?&gt;
&lt;/body&gt;
</code></pre>
