<?php
$new_result = mysqli_query($con, "SELECT input_cost FROM data_input");
while ($new = mysqli_fetch_array($new_result)) {
$sum += $new['input_cost'];
}
echo "<h2> total cost of this month is $".$sum. "</h2>";
?>
but the result say
<br>
Notice: Undefined variable: sum in C:\xampp\htdocs\work_shop\back_end\data_input_output\result.php on line 57
<br>
total cost of this month is $300
which is correct result....
<br>
How can I solve this problem...??
$sumbefore loop.