search

Home  >  Q&A  >  body text

The value of foreach is always empty

<?php
$sql="SELECT Ywyuan,count(Ddhao) as amount from main where format(Djshjian,'m')='$months' group by Ywyuan ";
     $rs=$db->Query($sql);
     while($data=$rs->FetchRow()){
        $mycard_arr[] = $data;
        }
if(!empty($mycard_arr)){
$xmlStr="<chart caption='当月客户下单记录总数统计' xAxisName='业务员' yAxisName='数量' showValues='1' 
formatNumberScale='0' showBorder='1' AlternateHGridColor='ff5904' divLineColor='ff5904' divLineAlpha='30' 
alternateHGridAlpha='5' canvasBorderColor='666666' baseFontColor='666666' lineColor='FF8000' 
baseFontSize='11'>";
foreach($mycard_arr as $value){
//这里不知道为什么 $value['Ywyuan'] 和 $value['amount']取不到值
echo "业务员".var_dump($value['Ywyuan']);
                 echo "<br>";
              //   echo "数字".var_dump($value['amount']);
                // echo "<br>";
// $value['Ywyuan']='张静';
// $value['amount']=800;
$xmlStr.="<set label='".$value['Ywyuan']."' value='".$value['amount']."' />";
}
$xmlStr.="</chart>";
echo renderChartHTML("./../lib07/FusionCharts/Line.swf","",$xmlStr,"myFirst", 900, 400, false,false);
echo "<br>";
}
?>


思展软件思展软件2358 days ago1398

reply all(3)I'll reply

  • 代码输入中...

    代码输入中...2018-07-25 21:48:10

    $mycard_arr array is wrong, check what your array format is like


    reply
    0
  • 思展软件

    $mycard_arr[0][0] $mycard_arr[0][1] $mycard_arr[0][2] ... $mycard_arr[1][1] Arrays have values. But when it reaches $value, it has no value.

    思展软件 · 2018-07-25 22:31:21
  • 思展软件

    思展软件2018-07-25 21:34:38

    The value can be called out in the statement, but the value will be empty once entering the foreach value.

    reply
    0
  • Cancelreply