dashboard.php #15
cata25tm opened this issue · 0 comments
$totalRevenue += $orderResult['paid'];
In this line, you're trying to add a value to $totalRevenue, which is initially an empty string, and $orderResult['paid'], which may also be a string based on your database's configuration.
To fix this issue, you can initialize $totalRevenue to 0, which is a number. And ensure that $orderResult['paid'] is also a number before performing the addition operation.
$totalRevenue = 0;
while ($orderResult = $orderQuery->fetch_assoc()) {
$totalRevenue += floatval($orderResult['paid']);
}
In the code snippet above, I initialized $totalRevenue to 0 instead of an empty string. And to make sure that $orderResult['paid'] is a number, I used the floatval() function which converts a variable to a float. If $orderResult['paid'] is a string representing a number, floatval() will convert it to a float so that the addition can proceed.
If your 'paid' field can contain decimal values, using floatval() is the right choice. If it's always a whole number, you could use intval() instead.