funkyz0r funkyz0r - 4 months ago 5x
PHP Question

Difference between two query

I have a question, it is possible to difference (mathematic operation) between two results?

Here is the code:

$row = $query->row();
echo "<b>Your total expenses:</b><br />". $row->TotalExpense;

$row = $query2->row();
echo "<b>Your total incomes:</b><br />". $row->TotalIncome;

Can I make something like:
TotalIncome - TotalExpense?

$x = query2
$y = query1

echo $x - $y;



If your start point is right. You kind of already had it.

$TotalExpense = $query->row()->TotalExpense;
$TotalIncome = $query2->row()->TotalIncome;

echo "<b>Your Balance:</b><br />". ($TotalIncome - $TotalExpense);