Note that there are some explanatory texts on larger screens.

plurals
  1. POHighcharts & Mysql
    primarykey
    data
    text
    <p>I need help with this code,I manage to extract data from a mysql database and convert them to a format required by Highcharts.</p> <pre><code>&lt;?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, ', '); ?&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Highcharts Example&lt;/title&gt; &lt;!-- 1. Add these JavaScript inclusions in the head of your page --&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../js/highcharts.js"&gt;&lt;/script&gt; &lt;!-- 1a) Optional: the exporting module --&gt; &lt;script type="text/javascript" src="../js/modules/exporting.js"&gt;&lt;/script&gt; &lt;!-- 2. Add the JavaScript to initialize the chart on document ready --&gt; &lt;script type="text/javascript"&gt; 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: &lt;?php echo json_encode($json_date,$row);?&gt; }, 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: '&lt;?php echo join($customer, ', ');?&gt;', data: [&lt;?php echo join($secondes, ', ');?&gt;] }] }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- 3. Add the container --&gt; &lt;div id="container" style="width: 1300px; height: 500px; margin: 0 auto"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The problem with this code is that it's only displays data from a single customer, so that the query returns data from multiple Customers.</p> <p>this method is good or there is another easier way to do that?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload