Query the summary rows or columns of data in an html table using PHP.

Source: Internet
Author: User
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"
  
  "; While ($ row = mssql_fetch_array ($ result) echo" 
   "; Echo" 
  
Store Amount
$ Row [0] $ Row [1]
";


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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.