funkyz0r funkyz0r - 1 year ago 90
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);