Php 谷歌图表没有列

Php 谷歌图表没有列,php,mysql,charts,Php,Mysql,Charts,我希望有人能帮上忙 我让它工作得很好,它突然无缘无故地停止了。我得到一个表没有列错误 我最初是从这个网站得到代码的-。不确定这是否有帮助 这是我的密码: 标题 <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/lib

我希望有人能帮上忙

我让它工作得很好,它突然无缘无故地停止了。我得到一个表没有列错误

我最初是从这个网站得到代码的-。不确定这是否有帮助

这是我的密码:

标题

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">
        // Load the Visualization API and the piechart package.
        google.load('visualization', '1', {'packages':['corechart']});

        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(drawChart);

        function drawChart() {
            var json = $.ajax({
                url: 'http://www.domain.com', // make this url point to the data file
                dataType: 'json',
                async: false
            }).responseText;

            // Create our data table out of JSON data loaded from server.
            var data = new google.visualization.DataTable(json);
            var options = {
                title: 'Active M&J Players by Team Assignment',
                is3D: 'true',
                width: 800,
                height: 600
            };
            // Instantiate and draw our chart, passing in some options.
            //do not forget to check ur div ID
            var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
            chart.draw(data, options);

            //setInterval(drawChart, 500 );
        }
    </script> 

//加载可视化API和piechart包。
load('visualization','1',{'packages':['corechart']});
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(drawChart);
函数绘图图(){
var json=$.ajax({
网址:'http://www.domain.com“,//使此url指向数据文件
数据类型:“json”,
异步:false
}).responseText;
//使用从服务器加载的JSON数据创建我们的数据表。
var data=new google.visualization.DataTable(json);
变量选项={
标题:“按团队分配的活跃M&J球员”,
is3D:'正确',
宽度:800,
身高:600
};
//实例化并绘制图表,传入一些选项。
//别忘了检查你的部门ID
var chart=new google.visualization.PieChart(document.getElementById('chart_div');
图表绘制(数据、选项);
//设定间隔(图纸,500);
}
PHP


您确定“数据”的格式正确吗?DataTable格式非常复杂。我建议您使用arrayToDataTableinstead@om_deshpande你的意思是用arrayToDataTable替换数组中的任何位置吗?@om_deshpande I updated var data=new google.visualization.DataTable(json);var data=google.visualization.arrayToDataTable(json);它什么也没回来。有什么想法吗?
    <?php
/* $server = the IP address or network name of the server
 * $userName = the user to log into the database with
 * $password = the database account password
 * $databaseName = the name of the database to pull data from
 * table structure - colum1 is cas: has text/description - column2 is data has the value
 */
$con = mysql_connect('database', 'username', 'password') or die('Error connecting to server');

mysql_select_db('database', $con); 

// write your SQL query here (you may use parameters from $_GET or $_POST if you need them)
$query = mysql_query('SELECT agelastsept as ageorder,CONCAT("U", agelastsept + 1 , "\'s") as agelastsept,total FROM members_family_view ORDER BY ageorder ASC');

$table = array();
$table['cols'] = array(
    /* define your DataTable columns here
     * each column gets its own array
     * syntax of the arrays is:
     * label => column label
     * type => data type of column (string, number, date, datetime, boolean)
     */
    // I assumed your first column is a "string" type
    // and your second column is a "number" type
    // but you can change them if they are not
    array('label' => 'agelastsept', 'type' => 'string'),
    array('label' => 'total', 'type' => 'number')
);

$rows = array();
while($r = mysql_fetch_assoc($query)) {
    $temp = array();
    // each column needs to have data inserted via the $temp array
    $temp[] = array('v' => $r['agelastsept']);
    $temp[] = array('v' => (int) $r['total']); // typecast all numbers to the appropriate type (int or float) as needed - otherwise they are input as strings

    // insert the temp array into $rows
    $rows[] = array('c' => $temp);
}

// populate the table with rows of data
$table['rows'] = $rows;

// encode the table as JSON
$jsonTable = json_encode($table);

// set up header; first two prevent IE from caching queries
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');

// return the JSON data
echo $jsonTable;
?>