Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard.php #15 #34

Open
cata25tm opened this issue Jun 11, 2023 · 0 comments
Open

dashboard.php #15 #34

cata25tm opened this issue Jun 11, 2023 · 0 comments

Comments

@cata25tm
Copy link

$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.

totoprayogo1916 added a commit to totoprayogo1916/inventory-management-system that referenced this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant