Hi all i have a new problem that needs some solvin
I'm trying to add data sets to Google's Javascript Motionchart from my SQL database via PHP
Here is what i have so far:
<?php
include "conn.php";
// Select all the rows in the markers table
$query = "SELECT * FROM wetteroe";
$result = mysql_query($query);
if (!$result) {
die("Invalid query: " . mysql_error());
}
$num = mysql_num_rows($result);
#while($row=@mysql_fetch_assoc($result)){
for($i=0;$i<1;$i++){
$row=@mysql_fetch_assoc($result);
$location[] = $row["location"];
$name[] = $row["name"];
$temp[] = $row["temp"];
$Datetime[] = $row["DATEtime"];
}
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['motionchart']});
function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(1);
data.addColumn('string', 'Location');
data.addColumn('date', 'Date');
data.addColumn('number', 'Temperature');
data.setValue(0, 0, alert(<?$location[0]?>));
data.setValue(0, 1, new Date (2011,09,10));
data.setValue(0, 2, 25);
var motionchart = new google.visualization.MotionChart(
document.getElementById('visualization'));
motionchart.draw(data, {'width': 800, 'height': 400});
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 800px; height: 400px;"></div>
</body>
</html>
THE ISSUE is that I am trying to get the javascript line:
data.setValue(0, 0, alert(<?$location[0]?>));
to get the php data. BUT I had to change the original line:
data.setValue(0, 0, 'Chicago'));
Since the change it doesn't display anything...
Anyone have an idea on how to get this sorted?