A report about the problem that PHP uses html tables to query summarized rows or columns of data: How does PHP read data from mssql and determine the total rows. This is part of the code. for example, the total amount column is required. how can I display and calculate the total in the last row of the table? thank you for your advice !! $ Query & nbsp; Select & nbsp; top & nbsp; 35 & nbsp; A. Branchdesc
A report:
PHP reads data from mssql and determines the method used to aggregate the rows.
This is part of the code. for example, the total amount column is required. how can I display and calculate the total in the last row of the table? thank you for your advice !!
$ 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 RetailType <> 1 and Convert (varchar (12), B. WorkDate, 112) = '$ searchdata'
Group by A. Branchdesc order by total desc ";
$ Result = mssql_query ($ query );
Echo "$ searchdata sales :";
Echo"
";Echo"
| Store |
Amount |
";While ($ row = mssql_fetch_array ($ result ))Echo"
| $ Row [0] |
$ Row [1] |
";Echo"
";
------ Solution ----------------------
$ 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"";