Questions about PHP combined with HTML table query data summary rows or columns
One of the reports:
PHP reads data from MSSQL, and the total line is calculated in what way.
This is part of the code, such as the amount required for the sum of a column, the last line of the table shows the total in what way to show and calculate, thank you veteran advice!!
$query = "SELECT Top a.branchdesc,sum (b.amount) Total
From Basebranch A Inner joins Retail B on A.branchid=b.branchid
Where b.doneflag=1 and B.delflag=0 and retailtype<>1 and Convert (varchar (), b.workdate,112) = ' $searchdata '
Group by A.branchdesc ORDER by total DESC ";
echo "$searchdata sales:";
echo "
"; Echo"
Stores |
Amount |
"; while ($row = Mssql_fetch_array ($result)) echo "
$row [0] |
$row [1] |
"; Echo"
";
------to solve the idea----------------------
$total = Array (' Total ', 0);
while ($row = Mssql_fetch_array ($result)) {
echo "$row [0] $row [1]";
$total [1] + = $row [1];
}
echo "$total [0] $rotal [1]";
echo "";