score:2
so in your php file....
add a line at the bottom that converts the table to json data. and give it a variable...
$table = array();
while($row = mysqli_fetch_assoc($result) )
{
$value=$row['value'];
$date=$row['date'];
$table[$value]=$date;
}
$jsondata = json_encode($table);
then in your other file.... echo that variable into your data object, in the javascript. remember to remove that whole random number generating function...(its just an example)
echoing php into javascript is definitely not considered good practice though. and it would be better to actually do an ajax call to your php file, and insert like that....i'll also show you how to do ajax.
<?php include 'test.php'; ?>
...
data: [<?php echo $jsondata;?>], //remove that function that was here..
// it was just to generate random numbers for the demo
....
}
edit / update for ajax...
so for ajax...instead of assigning a variable to $jsondata. just return it like so...(in your php file)
return json_encode($table);
then for this way....you dont include('test.php')
like you did before.
instead you just have this script inside your $(document).ready(function(){....
$.getjson('test.php', function(myjson) {
//and inside this function you put your highcharts stuff...
//remove that function() that generates random data
// and you will put the 'myjson' return object inside the 'data':[] array...
// provided you have structured your data correctly for highcharts, it should work...
// if not.... it'll be a start, and you're well on your way to debugging it
}
Source: stackoverflow.com
Related Query
- JavaScript PHP HighChart transform a PHP array to a javascript array
- How to convert php array into javascript array for Highchart JS
- Php 2D array into javascript array in highcharts
- PHP array reformat to highchart json ob
- array and object handling in javascript for getting highchart json data
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Highchart doesn't show the graph : error adding javascript array in series
- Array not in correct format in Javascript for use by HighChart
- Pass PHP result-set to JavaScript array in Highchart?
- How to pass JSP array to Javascript of highchart to generate a column chart
- Highchart series update in javascript
- Optimize JavaScript DrillDown code
- DB Array to expected javascript format
- How to convert a JavaScript object to array
- How to populate a Highcharts axis with string formatted data from a PHP array
- Highchart render in pdf generated using PHP mPdf
- JavaScript code inside TypeScript file .ts not working
- How to set values in JavaScript (Highcharts) using PHP
- Print Array in HighChart
- Passing a JavaScript function from JSON encoded PHP
- Highchart Zoom and X-Axis with String Array for Categories
- Adding data to a highchart chart using an array with IDs
- javascript variable not works in Highchart
- Php and MySQL with Highchart
- c# WPF Webbrowser with Highchart, Javascript from external source not working "An error has occurred in the script on this page"
- Highchart - Display JSON Data - MYSQL / PHP
- Transform array of objects into a transposed array of objects
- How to add php data into highchart js file in php
- Highchart : Json Array For ToolTip
- Generate image in a folder from Highchart in PHP
More Query from same tag
- Highcharts in angular scope problem with passing class reference
- Highcharts 3D with rCharts
- How to assign colors to categorical variables with a stable mapping in R highcharter?
- How can I style my highcharts solid gauge to have a background behind the percentage?
- different name series in highchart
- Highchart is not define error while deploying on server
- Separate panes / or style maximum gridlines in Highstock
- Set minPointLength for one of two series in highchart
- Return Highcharts using Ajax and Python
- Highcharts: X and Y Axis cross at zero in scatter chart
- Unable to trigger a click event on series data | Highchart
- Assign a color to every value in Javascript using HighCharts
- Highcharts tooltipformat for each series?
- HighCharts refresh size?
- How to make two charts using highchart show up in the same line side by side using div
- Unable to plot dynamically updating y-values on Highcharts spline plot
- How to import highchart-more into angular-cli 6 project
- Highcharts Pie Chart - Showing Negative value as "null" in legend
- Using highcharts for Rails (via LazyHighCharts), is there a tooltip for yDateFormat for having datetime data on the Yaxis?
- Axis values from database in highchart
- Highcharts: How to make Tooltip position to be visible in the Viewport
- Highchart - Set Time(Hour:Minute) on X axis
- Setting Additional Data to highcharts tooltip with formatter doesn't work if points count exceed threshold
- Highchart.js secondary axis not showing on the opposite side
- Highcharts load data from server ok, but not updating
- Spring MVC: How to display Hashmap keys and values in highcharts
- Highcharts.js will not render the chart, it says error "Cannot read property 'series' of undefined"
- Highcharts: show multiple days data on same chart making them overlpa each other to comparison
- Limitation for data-set (items) with Highstock/Highcharts?
- Implementing Jaspersoft Studio Community (v6.2.2) Custom Visualisation Component showing Highcharts chart