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: stacked bar shows percentages of stack
- Highcharts. Highlight line chart date interval on hover
- HighChart - How to change the icons of the highchart legend?
- Highchart export is calling events
- highchart remove first point
- How to generate proper csv file format using javascript
- Angular 3rd party library interaction
- Highchart Line and Range
- Cannot find type definition file for 'highcharts'
- Add CSS to a specific series' legend label in Highcharts
- Highcharts packed bubble chart not working for negative values
- how to make chart real time with 2 line and get data from php with highcharts
- Highcharts Bar Graph Remove Category when all bar values for category equal 0
- Highcharts: multiple yAxes labels overlap
- One label for multiple series
- Highcharts: Marker radius does not seem to work
- how to add items to an array dynamically in javascript
- Yii HighCharts not displaying from $vars but display when hardcoded
- Server side chart .svg export with Highcharts and PhantomJS, error loading data from .csv file
- Highchart: exact distance between ticks
- Highchart (stockchart) Yaxis on opposite side miss align when left axis is not visible
- Trying to create Highcharts element in Polymer
- Highcharts - Multiple charts with same object
- 3D Column chart not working with sliders in asp .net project
- Additive Color in Highcharts
- Highcharts Orientation
- HighCharts - compare series with values instead of percentage
- Why does highcharts not accept an array for second y axis?
- R Shiny - Highcharts: Tooltip delay before display
- Highcharts synchronization with multiple yaxis