I'm making a simple webpage to keep my company records of how many stuff we bought and I ran into a small problem. I have this code:

```
$query = mysql_query("SELECT * FROM lisicara WHERE (datum BETWEEN '$a' AND '$b') ORDER BY datum ASC");
while($row = mysql_fetch_array($query)) {
    $datum = $row['datum'];
    $kg_kupljeno = $row['kg_kupljeno'];
    $cena1 = $row['cena1'];
    $kg_prodato = $row['kg_prodato'];
    $cena2 = $row['cena2'];
    $napomena = $row['napomena'];

    $ukupno1 = $kg_kupljeno * $cena1;
    $ukupno2 = $kg_prodato * $cena2;
    $razlika = $ukupno2 - $ukupno1;

    echo '
        <tr>
            <td>'.$datum.'</td>
            <td>'.number_format($kg_kupljeno).'</td>
            <td>'.number_format($cena1).'</td>
            <td>'.number_format($ukupno1).'</td>
            <td>'.number_format($kg_prodato).'</td>
            <td>'.number_format($cena2).'</td>
            <td>'.number_format($ukupno2).'</td>
            <td>'.number_format($razlika).'</td>
            <th>'.$napomena.'</th>
        </tr>';
}

```

After this while loop it shows a tr where it sums all from table. Problem is that `$ukupno1`, `$ukupno2` and `$razlika` are not displaying from database but they are calculating with PHP `$ukupno1 = $kg_kupljeno * $cena1`.

How to sum all `$ukupno1` and display it after the while loop?