A report on the query of summary rows or columns by PHP in combination with html tables:
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. branchdesc, sum (B. amount) totalFrom BaseBranch A Inner Join Retail B On. branchID = B. branchIDWhere B. doneFlag = 1 and B. delFlag = 0 and RetailType <> 1 and Convert (varchar (12), B. workDate, 112) = '$ searchdata' Group by. 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"
";
Reply to discussion (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"";
$ 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"";
Thank you. correct. Many functions need to be learned for beginners! I still have many questions to ask. thank you again!