funkyz0r funkyz0r - 2 years ago 135
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;


Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download