无法在使用图形时从数据库获取数据到脚本标记

时间:2015-04-17 10:59:31

标签: php mysql graph charts

plotOptions: {
    column: {
        pointPadding: 0.2,
        borderWidth: 0
    }
},

series: [{
    name: 'Not Completed',
    data: [<?php echo json_encode($TotalNotCompleted); ?>]
/* here how to write query to fetch data from database, to make my graph work dynamically */
}, {
    name: 'Completed',
    data: [<?php echo json_encode($TotalCompleted); ?>]
}]

1 个答案:

答案 0 :(得分:0)

plotOptions: {
    column: {
        pointPadding: 0.2,
        borderWidth: 0
    }
},
series: [
    <?
    $QueryTST=mysql_query("SELECT * FROM TotalCounterSales WHERE AdminCity='$City' AND AdminStore='$StoreNo' AND SalesDate='$TodaysDate'");
    while($RowQTST=mysql_fetch_array($QueryTST))
    {
    $ProductNo=$RowQTST['ItemNo'];
        $QueryProductName=mysql_query("SELECT * FROM products WHERE PId='$ProductNo' ");
        while($RowQPN=mysql_fetch_array($QueryProductName))
        {
            $ProductName=$RowQPN['name'];
        }
    ?>
    { name: "<?echo $ProductName;?>", data: [<?echo $RowQTST['Quantity'];?>]}, 
    <?}?>
]