phpquery - Php sum value once when loop start -
hi have value in variable want add value first time when loop start not always. example
<?php $balance = 100; while($row = mysql_fetch_array($query) { echo $row['amount'] + $balance; // example $row['amount'] 50, 20 , 30; } ?>
i want result follow
<?php 150 170 200 ?>
sample code..
$balance = 100; $counter=1; $total=0; while($row = mysql_fetch_array($query) { if($counter==1) { $total=$row['amount'] + $balance; // example $row['amount'] 50, 20 , 30; } else { $total = $row['amount']+$total; } echo $total.'<br>'; $counter++; }
Comments
Post a Comment