Why this code is not working fine ?
I have the php code that generates do jsontable but I cannot use it in the html?
Any idea ?
<html>
<head>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart()
{
var data = new google.visualization.DataTable(<?php
$conn = oci_connect('eri', 'senha123', 'localhost/orcl');
if (!$conn) {
$erro = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = oci_parse($conn, "select tipo, tempo from eri");
oci_execute($query);
$rows = array();
$table = array();
$table['cols'] = array(
array('label' => 'tipo', 'type' => 'string'),
array('label' => 'tempo', 'type' => 'int'),
);
$rows = array();
while($r = oci_fetch_array($query, OCI_ASSOC+OCI_RETURN_NULLS)) {
$temp = array();
$temp[] = array('v' => (string) $r['TIPO']);
$temp[] = array('v' => (int) $r['TEMPO']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsontable = json_encode($table);
echo $jsontable;
?>
);
var options = {
title:'Sensors Data',
legend:{position:'bottom'},
chartArea:{width:'95%', height:'65%'}
};
var chart = new google.visualization.LineChart(document.getElementById('line_chart'));
chart.draw(data, options);
}
</script>
<style>
.page-wrapper
{
width:1000px;
margin:0 auto;
}
</style>
</head>
<body>
<div class="page-wrapper">
<br />
<h2 align="center">SHOW 1 - Display Google Line Chart with JSON PHP & Oracle </h2>
<div id="line_chart" style="width: 100%; height: 500px"></div>
</div>
</body>
</html>