关于php结合html表格查询数据汇总行或列的问题
如图的一个报表:
php从mssql读取数据,合计行用什么方式求出。
这是部份代码,比如要求金额一列的合计,在表的最后一行显示合计以什么方式显示出并计算,谢谢各位老手指教!!
$query = select top 35 a.branchdesc,sum(b.amount)total
from basebranch a inner join retail b on a.branchid=b.branchid
where b.doneflag=1 and b.delflag=0 and retailtype1 and convert(varchar(12),b.workdate,112)='$searchdata'
group by a.branchdesc order by total desc;
$result = mssql_query($query);
echo $searchdata 的销售为:;
echo ;
echo 门店 金额
;
while($row = mssql_fetch_array($result))
echo $row[0] $row[1]
;
echo
;
------解决思路----------------------
$total = array('合计', 0);
while($row = mssql_fetch_array($result)) {
echo $row[0] $row[1]
;
$total[1] += $row[1];
}
echo $total[0] $rotal[1]
;
echo
;