php中变量的使用有关问题
程序员文章站
2024-02-08 20:06:22
...
php中变量的使用问题
从数据库中获得了各区的销售金额和销售数量,要对数量和金额求和。代码如下:
从数据库中获得了各区的销售金额和销售数量,要对数量和金额求和。代码如下:
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 "华东区";
break;
case "C":
echo "东北区";
break;
case "N":
echo "华北区";
break;
case "W":
echo "西大区(W)";
break;
case "H":
echo "华中区";
break;
case "S":
echo "华南区";
break;
case "F":
echo "华东区(经销)";
break;
case "T":
echo "西大区(T)";
break;
}
?>-- --
$all_sales_amount+=$row1["area_salesgoodssum"];
$all_sales_money+=$row1["area_salesmoney"];
echo '循环中数量'.$all_sales_amount."金额".$all_sales_money."
";
}
?>