Hi 

Can anyone help me, I have a php file read data from database it works, I 
now want to put that data in a google line chart but am finding it 
difficult to do. Please see the code below, any help on where I am going 
wrong would be greatly appreciated 

<?php
include('dbconn.php');
 $connection = DatabaseConnection::getInstance();
 $myquery = "SELECT id, rssi FROM tbl_meter_read WHERE accesspoint = 1";
$result = mysqli_query($connection->getConnection() , $myquery);
 // All good?
if ( !$result ) {
// Nope
$message  = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die( $message );
} 

$table = array(
'cols' => array(
    //Labels for the chart, these represent the column titles
    array('label' => 'id', 'type' => 'number'),
    array('label' => 'rssi', 'type' => 'number')
    ),
'rows' => array()
);
 while ($row = mysqli_fetch_assoc($result)) {
    $table['rows'][] = array(
        'c' => array(
            array('v' => $row['id']),
            array('v' => $row['rssi'])
        )
    );
}

$connection->__destruct(); 
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and 
media queries -->
    <!--[if lt IE 9]>
      <script 
src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js";></script>
      <script 
src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js";></script>
    <![endif]-->
    <!-- Load jQuery -->
    <script language="javascript" type="text/javascript" 
        
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js";>
    </script>
    <!-- Load Google JSAPI -->
    <script type="text/javascript" 
src="https://www.google.com/jsapi";></script>
    <script type="text/javascript">
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);

        function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('number', 'ID');
        data.addColumn('number', 'RSSI');
        data.addRows([
        $table
        ]);

            var options = {
                title: 'RSSI READINGS'
            };

            var chart = new google.visualization.LineChart(
                        document.getElementById('chart_div'));
            chart.draw(data, options);
        }

    </script>
  </head>
  <body>   
    <div id="chart_div" style="width: 900px; height: 500px;"> </div>  
  </body>
</html>

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to