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 export in IE malformed
- "adaptToUpdatedData: false" in highcharts don`t works if I put series in chart with "addSeries"
- How can I wrap long text labels in highchart nested groups
- compare chart series array with new array to determine adds/removes
- High charts queue chart updates after ajax with multiple charts in firefox
- How would I overlay a scatter plot on a mirrored bar chart in Highcharts?
- having issue when updation Highcharts object using highcharts-ng directive
- highcharts - pulling data from HTML but converting the strings to number
- problem with highcharts series option
- How to disable Angular Drop Down if the model is null or empty?
- Highcharts data series label. for each data point
- Build charts from polling JSON data
- Why any of highcharts demo example doesn't work?
- Can a Highcharts Polar chart have a logarithmic y-axis?
- Remove tooltip from level 2 of treemap (using highcharts)
- Custom Notation in HighChart series
- Highcharts Combo Graph Overlapping eachother
- How can I make some events are clickable or others not in Timeline Highchart?
- Error: Highcharts error #13 ionic angular
- Highcharts Arearange has no zoom animation above certain length
- Highcharts treemap top and left borders missing
- Can't update highcharts data on button - var visibility or events handle issue
- Highcharts v7.1.2 width scaling issue when using css transform scale
- Highcharts zoom issue when panning reversed xAxis
- Adding a colored border (not shadow) to the label text on a Highcharts treemap
- Highchart.Chart() on Marionette App
- different approximation methods (dataGrouping) for each Series in one Highstocks-Chart?
- How to import highcharts-more
- Highcharts - Gray out only title in legend
- Highcharts: Cannot read property 'chart' of undefined