嗨,我的数据库中有两个表 1. 收入 2. 结果 收入表有 ID、日期、价格也结果表完全相同,我显示今天的价格总和
mysql_select_db($database_conn, $conn);
$query_gelen_gun = sprintf ("SELECT SUM(tutar) FROM cepbank WHERE tarih >= DATE(NOW())");
$gelen_gun = mysql_query($query_gelen_gun, $conn) or die(mysql_error());
$row_gelen_gun = mysql_fetch_assoc($gelen_gun);
$totalRows_gelen_gun = mysql_num_rows($gelen_gun);
mysql_select_db($database_conn, $conn);
$query_giden_gun = sprintf ("SELECT SUM(tutar) FROM cepbank_out WHERE tarih >= DATE(NOW())");
$giden_gun = mysql_query($query_giden_gun, $conn) or die(mysql_error());
$row_giden_gun = mysql_fetch_assoc($giden_gun);
$totalRows_giden_gun = mysql_num_rows($giden_gun);
. . .
<p>Total Income for Today:<?php echo $row_gelen_gun['SUM(tutar)']; ?></p>
<p>Total Outcome for Today:<?php echo $row_giden_gun['SUM(tutar)']; ?></p>
现在我如何显示这两个结果的平衡,例如$row_gelen_gun['SUM(tutar)']
= 100 和$row_giden_gun['SUM(tutar)']
= 50
余额应该是 100-50 =50 ?
注意:查询中的价格=tutar