<?php
$db = mysqli_connect("127.0.0.1", "root", "","main_t");
mysqli_set_charset($db,"utf8");
function getDataString(){
global $db;
$query = "SELECT `stars`,`age` FROM `main_t`";
$res =mysqli_query($db,$query);
$data = '{"cols": [';
$data .= '{"id":"","label": "Кандидатов","type":"number"},';
$data .= '{"id":"","label": "Эффективность","type":"number"}';
$data .= '],"rows":[';
while($row =mysqli_fetch_assoc($res)){
$data .='{"c":[{"v":"' . $row['stars']. '"},{"v":'.$row['age'].'}]},';
}
$data =rtrim($data,',');
$data .=']}';
return $data;
}
echo json_encode($data);
?>