Php 海图及;Mysql

Php 海图及;Mysql,php,javascript,mysql,json,highcharts,Php,Javascript,Mysql,Json,Highcharts,我需要这段代码的帮助,我设法从mysql数据库中提取数据,并将其转换为Highcharts所需的格式 <?php $query =mysql_query("select date_format(connect_time,'%Y-%m-%d %H %i') AS date, Customers.name as customer, Sum(duration) as secondes

我需要这段代码的帮助,我设法从mysql数据库中提取数据,并将其转换为Highcharts所需的格式

<?php
$query =mysql_query("select
               date_format(connect_time,'%Y-%m-%d %H %i') AS date,
               Customers.name as customer,
               Sum(duration) as secondes
               from CDR_Vendors
               inner join Customers on (CDR_Vendors.i_customer = Customers.i_customer)
               where
               i_vendor='32'
               and
               connect_time between '2010-09-01 00:00:00' and '2010-09-01 00:10:00'
               group by date
               ORDER BY date", $link) or die(mysql_error());
$row = mysql_fetch_assoc($query);
$customer[] = $row['customer'];
$json_secondes = array();
$json_date = array();
do{
$secondes[] = $row['secondes'];
array_push($json_secondes, $row['secondes']);
array_push($json_date, $row['date']);
}
while($row = mysql_fetch_assoc($query));
//echo json_encode($json_secondes,$row);
//echo json_encode($json_date,$row);
//echo join($secondes, ', ');
?>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Highcharts Example</title>


      <!-- 1. Add these JavaScript inclusions in the head of your page -->
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
      <script type="text/javascript" src="../js/highcharts.js"></script>

      <!-- 1a) Optional: the exporting module -->
      <script type="text/javascript" src="../js/modules/exporting.js"></script>


      <!-- 2. Add the JavaScript to initialize the chart on document ready -->
      <script type="text/javascript">

         var chart;
         $(document).ready(function() {
            chart = new Highcharts.Chart({
               chart: {
                  renderTo: 'container',
                  defaultSeriesType: 'column'
               },
               title: {
                  text: 'Monthly Average Rainfall'
               },
               subtitle: {
                  text: 'Source: WorldClimate.com'
               },
               xAxis: {
                  categories: <?php echo json_encode($json_date,$row);?>
               },
               yAxis: {
                  min: 0,
                  title: {
                     text: 'Rainfall (mm)'
                  }
               },
               legend: {
                  layout: 'vertical',
                  backgroundColor: '#FFFFFF',
                  align: 'center',
                  verticalAlign: 'top',
                  x: 100,
                  y: 70
               },
               tooltip: {
                  formatter: function() {
                     return ''+
                        this.x +': '+ this.y +' Min';
                  }
               },
               plotOptions: {
                  column: {
                     pointPadding: 0.2,
                     borderWidth: 0
                  }
               },
                    series: [{
                  name: '<?php echo join($customer, ', ');?>',
                  data: [<?php echo join($secondes, ', ');?>]

               }]
            });


         });

      </script>

   </head>
   <body>

      <!-- 3. Add the container -->
      <div id="container" style="width: 1300px; height: 500px; margin: 0 auto"></div>


   </body>
</html>

海图示例
var图;
$(文档).ready(函数(){
图表=新的高点图表。图表({
图表:{
renderTo:'容器',
defaultSeriesType:“列”
},
标题:{
文字:“月平均降雨量”
},
副标题:{
文本:'来源:WorldClimate.com'
},
xAxis:{
类别:
},
亚克斯:{
分:0,,
标题:{
文字:“降雨量(毫米)”
}
},
图例:{
布局:“垂直”,
背景颜色:“#FFFFFF”,
对齐:'居中',
垂直排列:“顶部”,
x:100,
y:70
},
工具提示:{
格式化程序:函数(){
返回“”+
this.x+':'+this.y+'Min';
}
},
打印选项:{
专栏:{
点填充:0.2,
边框宽度:0
}
},
系列:[{
名称:“”,
数据:[]
}]
});
});
这段代码的问题在于它只显示来自单个客户的数据,因此查询返回来自多个客户的数据

此方法很好,或者有另一种更简单的方法可以做到这一点?

您可以检查:


我希望这将帮助您使用CSV

尝试使用
内爆(“,”,$customer)
内爆(',',$secondes)
而不是加入
功能。

您的代码是否只显示查询列表中的最后一个客户?是的,确实如此,您知道如何解决此问题吗?