score:2

Accepted answer

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

}

Related Query

More Query from same tag