Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Highchards—从数据库加载数据_Php_Mysql_Highcharts - Fatal编程技术网

Php Highchards—从数据库加载数据

Php Highchards—从数据库加载数据,php,mysql,highcharts,Php,Mysql,Highcharts,我正在寻找将数据从dbase加载到Hittcharts的帮助。 Highcharts数据加载入口如下所示: <script type="text/javascript"> jQuery(function() { // Create the chart window.chart = new Highcharts.StockChart({ chart: { renderTo: 'container'

我正在寻找将数据从dbase加载到Hittcharts的帮助。 Highcharts数据加载入口如下所示:

<script type="text/javascript">
jQuery(function() {
        // Create the chart 
        window.chart = new Highcharts.StockChart({
            chart: {
                renderTo: 'container'
            },

            rangeSelector: {
                selected: 1
            },

            title: {
                text: 'USD to EUR exchange rate'
            },

            xAxis: {
                maxZoom: 14 * 24 * 3600000 // fourteen days
            },
            yAxis: {
                title: {
                    text: 'Exchange rate'
                }
            },

            series: [{
                name: 'USD to EUR',
                data: usdeur
            }]
        });
    });
    </script>
从dbase SELECT中,我有:

$data_date = array();
$data_data = array();

foreach($STH as $row)
{

$date1 = $row['date'];
$date2 = explode("-", $date1);
$date3 = $date2[0].",".$date2[1].",".$date2[2];


$data_date[] = $date3;                      // date in scheme 2011,1,3
$data_data[] = $row['index_p_actual'];      // data like 0.7488
}
  • 关于日期的信息-$date\u date[]
  • 有关相关数据的信息-$data\U data[]
我想在线加载数据,而不是通过任何像csv这样的外部文件

我的问题是-如何将$data\u date和$data\u数据连接到一个数据袋中,以接收完全虚拟的列表,如

[Date.UTC(2011,1,3),0.7488],
[Date.UTC(2011,2,6),0.6983],
[Date.UTC(2011,3,8),0.6961],
[Date.UTC(2011,4,9),0.6945]
highcharts的建议是使用:

series: [{
data: [<?php echo join($data, ',') ?>]
}]
系列:[{
数据:[]
}]
但是我有$data和$date-如何加入它?使用php join,我只能使用一个变量[]


嗯,或者是另一种更好的方式?

如果我很好地理解你,我想你应该这样做:

$data_date = array();
$data_data = array();

foreach($STH as $row)
{

$date1 = $row['date'];
$date2 = explode("-", $date1);
$date3 = $date2[0].",".$date2[1].",".$date2[2];


$data_date[] = $date3;                      // date in scheme 2011,1,3
$data_data[] = $row['index_p_actual'];      // data like 0.7488
$data_highcharts[] = [$date3,$row['index_p_actual']]

}
然后将
$data\u highcharts[]
发送到JavaScript,其格式如下:

[[date1,data1],[date2,data2],...]

我理解你的想法,但我们有“[”、“日期”、“UTC”“等。我们可以连接所有这些元素,但我认为,这必须是另一种方式,简单的一种,对于Highcharts系统来说是典型的。@Andrew我相信我提到的很简单,因为你只需将一个变量传递给JS,JS有所有要绘制的点。但我希望有人指出你需要什么:)我尝试通过这种方式加载数据:)
[[date1,data1],[date2,data2],...]