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

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -