数据未在MYSQL中加载HighChart

时间:2016-05-02 07:44:10

标签: php mysql highcharts

我最近开始从事Highchart的工作。我没有深刻的知识。但我仍然在尝试我的水平。我尝试了很少的代码,但我没有得到任何结果。浏览器控制台没有加载任何内容,它显示为空白。能帮我指点下一步做什么吗?我最好的尝试了我的水平。请我出去。

这是我的代码:

数据库编码:php.data

<?php
    //open connection to mysql db
    $connection = mysqli_connect("localhost","root","root","demo") or die("Error " . mysqli_error($connection));

    //fetch table rows from mysql db
    $sql = "select * from project_requests";
    $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));


    //close the db connection
    mysqli_close($connection);
?>

的index.php

<!DOCTYPE HTML>
<?php 

include_once 'data.php'; 


?>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>

        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
        <style type="text/css">
${demo.css}
        </style>
        <script type="text/javascript">
$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        },
        title: {
            text: 'Browser market shares January, 2015 to May, 2015'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Brands',
            colorByPoint: true,
            data: [

            <?php 

            //$sql = mysqli_query("select * from project_requests")
            while($res=mysql_fetch_array($sql)){
            ?>

            ['<?php echo $res['month']; ?>', 45.0],


         <?php
            }
         ?>


      ]
        }]
    });
});
        </script>
    </head>
    <body>

<script src=
"https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>

    </body>
</html>

我的sql:数据库快照

Schema:: Demo Table:: project_requests

0 个答案:

没有答案