php中变量的使用问题
从数据库中获得了各区的销售金额和销售数量,要对数量和金额求和。代码如下:
<br /> <?PHP<br /> <br /> ob_start();<br /> require_once 'DB.php';<br /> ob_end_clean();<br /> $db=DB::Connect();<br /> $result=$db->QueryLastMonth();<br /> $result1=$db->QueryLastMonthByArea();<br /> $all_sales_amount;<br /> $all_sales_money;<br /> echo 'begin '.$all_sales_amount;<br /> while($row1= sybase_fetch_assoc($result1))<br /> {<br /> ?><br /> <tr><br /> <th data-options="field:'itemid',width:80"><?php <br /> switch($row1["areacode"]){<br /> case "E":<br /> echo "华东区";<br /> break;<br /> case "C":<br /> echo "东北区";<br /> break;<br /> case "N":<br /> echo "华北区";<br /> break;<br /> case "W":<br /> echo "西大区(W)";<br /> break;<br /> case "H":<br /> echo "华中区";<br /> break;<br /> case "S":<br /> echo "华南区";<br /> break;<br /> case "F":<br /> echo "华东区(经销)";<br /> break;<br /> case "T":<br /> echo "西大区(T)";<br /> break;<br /> }<br /> ?></th><br /> <th data-options="field:'productid',width:80"><?php echo $row1["area_salesgoodssum"]?></th><br /> <th data-options="field:'listprice',width:100,align:'right'"><?php echo $row1["area_salesmoneysum"]?></th><br /> <th data-options="field:'unitcost',width:80,align:'right'">--</th><br /> <th data-options="field:'status',width:60,align:'center'">--</th><br /> </tr><br /> <br /> <?php <br /> $all_sales_amount+=$row1["area_salesgoodssum"];<br /> $all_sales_money+=$row1["area_salesmoney"];<br /> echo '循环中数量'.$all_sales_amount."金额".$all_sales_money."<br>";<br /> }<br /> ?><br /> </thead><br /> </table><br /> </div><br /> <br /> <br /> <div class="easyui-draggable" data-options="handle:'#title'" style="width:220px;height:160px;background:#fafafa;border:1px solid #ccc;margin-top:10px"><br /> <div id="title" style="padding:5px;background:#ccc;color:#FA0000">销售简报<?php ?></div><br /> <span>总金额:<?php echo $all_sales_money; ?> </span><br><br /> <span>总数量:<?php echo $all_sales_amount?> </span><br />