Hi,
I'd like to create a GViz of some data in a MySql Database and I'm having problems.
Here is the source so far:
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');
mysql_select_db($dbname);
$int_y_pos = -1;
$int_y_step_small = 1;
$sql = "SELECT * from table')";
$sql = mysql_query($sql);
$rownum = mysql_num_rows($sql);
?>
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></
script>
<script type="text/javascript">
google.load("visualization", "1", {packages:
["table"]});
google.setOnLoadCallback(drawData);
function drawTable() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'column1');
data.addColumn('string', 'column2');
<?php
echo " data.addRows($rownum);\n";
while($row = mysql_fetch_assoc($sql)) {
$int_y_pos += $int_y_step_small;
echo " data.setValue(" . $int_y_pos . ", 0, new column1(" .
$row['column1'] . "));\n";
echo " data.setValue(" . $int_y_pos . ", 0, new column2(" .
$row['column2'] . "));\n";
}
?>
var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(data, {showRowNumber: true});
google.visualization.events.addListener(table, 'select', function() {
var row = table.getSelection()[0].row;
alert('You selected ' + data.getValue(row, 0));
});
}
</script>
</head>
<body>
<div id="table_div" style="width: 940px; height: 240px;"></div>
</body>
</html>
Any help or examples of previous previous integrations would be great.
Thanks
Gareth