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

2021-12-24 00:00:00 graph charts php mysql
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); ?>]
}]

推荐答案

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'];?>]}, 
    <?}?>
]

相关文章