php loop display sum before loop that does calculation
<p>Is it possible for me to display the sum at the heading before the program runs through?</p>

<pre><code>while (($data = fgetcsv($handle, 1000, ","))) {

if($data[2] != $prevRow2) {

 echo '&lt;/div&gt;';
 if ($prevRow2 != '') {
  $stringData .= '&lt;/Payment&gt;';
 }
 echo "&lt;div id=\"row\"&gt;";
 echo $sum;
 $row++;
           $sum = 0;
}
 else { echo "&lt;div id=\"filler\"&gt;&lt;/div&gt;";}

 foreach ($data as $key =&gt; $d) {
  if ($key != 1) {
   echo "&lt;div class=\"field\"&gt;" .$d . "&lt;/div&gt;";
  }
 }

 $sum +=$data[6]; 
 echo "&lt;br/&gt;";
 echo "&lt;div id=\"filler\"&gt;&lt;/div&gt;"; 
                      $prevRow2 = $data[2];
} 

fclose($handle);
}
</code></pre>
