来自php中的mysql数据库的Javascript数组

 var chartData = [{
     "country": "Czech Republic",
     "litres": 156.9
 }, {
     "country": "Ireland",
     "litres": 131.1
 }, {
     "country": "Germany",
     "litres": 115.8
 }, {
     "country": "Australia",
     "litres": 109.9
 }, {
     "country": "Austria",
     "litres": 108.3
 }, {
     "country": "UK",
     "litres": 65
 }, {
     "country": "Belgium",
     "litres": 50
 }];

i want to create this array using mysql database in php how can i do it ?

You can fetch the record from database as array format then it will convert into a json object. Try below code

// fetch the record form mysql table using mysqli_fetch_assoc() and store it in $chartData
    // then use json_decode() function used to convert the array into object format
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    $chartData[] = array("country"=> "Czech Republic", "litres"=> 156.9);
    echo '<pre>';
    var_dump(json_encode($chartData));

I think it will helpful for you.. :-)