Usage of variables in php

Source: Internet
Author: User
The usage of variables in php obtains the sales amount and sales quantity of each region from the database. sum the quantity and amount. The code is as follows: & lt ;? PHPob_start (); require_once & nbsp; 'DB. php'; ob_end_clean (); & nbsp; & n usage of variables in php
Obtain the sales amount and sales quantity of each region from the database, and sum the quantity and amount. The code is as follows:


Ob_start ();
Require_once 'DB. php ';
Ob_end_clean ();
$ Db = DB: Connect ();
$ Result = $ db-> QueryLastMonth ();
$ Result1 = $ db-> QueryLastMonthByArea ();
$ All_sales_amount;
$ All_sales_money;
Echo 'begin'. $ all_sales_amount;
While ($ row1 = sybase_fetch_assoc ($ result1 ))
{
?>

Switch ($ row1 ["areacode"]) {
Case "E ":
Echo "East China ";
Break;
Case "C ":
Echo "Northeast region ";
Break;
Case "N ":
Echo "North China ";
Break;
Case "W ":
Echo "West Region (W )";
Break;
Case "H ":
Echo "Central China ";
Break;
Case "S ":
Echo "South China ";
Break;
Case "F ":
Echo "East China (distribution )";
Break;
Case "T ":
Echo "West Region (T )";
Break;
}
?>


--
--


$ All_sales_amount + = $ row1 ["area_salesgoodssum"];
$ All_sales_money + = $ row1 ["area_salesmoney"];
Echo 'number in a loop '. $ all_sales_amount. "amount". $ all_sales_money ."
";
}
?>






Sales briefing
Total amount:  

Total quantity:  


$ All_sales_amount indicates the sales quantity, and $ all_sales_money indicates the sales amount. However, the result of calculating the sales quantity in the running result is incorrect. the sales amount is always 0 (as shown below). What is the problem with the above code?
Share: More

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.