两个查询之间的区别
Difference between two query
我有一个问题,两个结果之间可以有差异(数学运算)吗?
代码如下:
<?php
$row = $query->row();
echo "<b>Your total expenses:</b><br />". $row->TotalExpense;
?>
<?php
$row = $query2->row();
echo "<b>Your total incomes:</b><br />". $row->TotalIncome;
?>
我可以做类似的东西吗:
总收入 - 总支出?
<?php
$x = query2
$y = query1
echo $x - $y;
?>
谢谢!
<?php
$x = $row->TotalIncome;
$y = $row->TotalExpense;
echo "<b>Balance:</b><br />" . ($x - $y);
?>
<?php
$query1 = array(
"TotalExpense" => 200.42
);
$query2 = array(
"TotalIncome" => 500.42
);
$row1 = (object)$query1;
echo "<b>Your total expenses:</b>". $row1->TotalExpense ."<br />";
$row2 = (object)$query2;
echo "<b>Your total incomes:</b>". $row2->TotalIncome ."<br />";
echo "<b>Your balance:</b>". ($row2->TotalIncome - $row1->TotalExpense) ."<br />";
此输出结果
<b>Your total expenses:</b>200.42<br /><b>Your total incomes:</b>500.42<br /><b>Your balance:</b>300<br />
如果你的起点是对的。你有点已经拥有它了。
<?php
$TotalExpense = $query->row()->TotalExpense;
$TotalIncome = $query2->row()->TotalIncome;
echo "<b>Your Balance:</b><br />". ($TotalIncome - $TotalExpense);
?>
我有一个问题,两个结果之间可以有差异(数学运算)吗?
代码如下:
<?php
$row = $query->row();
echo "<b>Your total expenses:</b><br />". $row->TotalExpense;
?>
<?php
$row = $query2->row();
echo "<b>Your total incomes:</b><br />". $row->TotalIncome;
?>
我可以做类似的东西吗: 总收入 - 总支出?
<?php
$x = query2
$y = query1
echo $x - $y;
?>
谢谢!
<?php
$x = $row->TotalIncome;
$y = $row->TotalExpense;
echo "<b>Balance:</b><br />" . ($x - $y);
?>
<?php
$query1 = array(
"TotalExpense" => 200.42
);
$query2 = array(
"TotalIncome" => 500.42
);
$row1 = (object)$query1;
echo "<b>Your total expenses:</b>". $row1->TotalExpense ."<br />";
$row2 = (object)$query2;
echo "<b>Your total incomes:</b>". $row2->TotalIncome ."<br />";
echo "<b>Your balance:</b>". ($row2->TotalIncome - $row1->TotalExpense) ."<br />";
此输出结果
<b>Your total expenses:</b>200.42<br /><b>Your total incomes:</b>500.42<br /><b>Your balance:</b>300<br />
如果你的起点是对的。你有点已经拥有它了。
<?php
$TotalExpense = $query->row()->TotalExpense;
$TotalIncome = $query2->row()->TotalIncome;
echo "<b>Your Balance:</b><br />". ($TotalIncome - $TotalExpense);
?>