I want to show daily balance of valut. For example 01.01. is balance 500€ and 02.01. I add 300€ som balance form 02.01. will be 800€
I have a code:
$balance = 'SELECT date, SUM(suma) AS DailyBalance FROM pokladna GROUP BY `date`';
$result = mysql_query($balance);
while ($row = mysql_fetch_array($result)) {
echo '<div>'.$row['date'].' <---> '.str_replace('EUR','€', money_format('%.2n',
$row['DailyBalance'])).'</div><br>';
}
Its return
2017-01-01 157,10 €
2017-01-02 -52,00 €
2017-01-03 241,36 €
But I want
2017-01-01 157,10 €
2017-01-02 107,10 € (-52€)
2017-01-03 348,46 € (+241,36€)
Can anybody help? Is there way do this without creting extra table?