Hi there,
I have a code that subtracts the sum one table from the sum of another table in php
i have echo the amount. i have been trying the if else statement to determine whether the figure is a positive number or a negative number. If the number is positive i want it to echo profit but if the number is negative i want it to echo loss
for example if the total was £50.00 it will echo Profit : £50 but if the total was £-50.00 it would echo Loss -£50
my sql query at moment
$sql = "SELECT ((SELECT SUM(iamount) FROM income) - (SELECT SUM(eamount) FROM expenses)) AS total";
my echo
echo "Total Profit (Loss is Minus) :   £ " .$row["total"]. "<br>";
i have tried this but does not work
if(total >= 0.00){
echo "Total Profit :   £ " .$row["total"].";
} else{
echo "Total Loss :   £ " .$row["total"].";
}
any help please ?