<?php
$con=mysql_connect("server","user","pass") or die("Failed to connect with database!!!!");
mysql_select_db("databasename", $con);
// Later on I'll need to change the way to connect in a more secured way).
$sth = mysql_query("SELECT * FROM google tablename");
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
array('type' => 'string', 'label' => 'PersonName'),
array('type' => 'date', 'label' => 'start'),
array('type' => 'date', 'label' => 'end'));
//$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$start = date("Y-m-d");
$end = date("Y-m-d");
$temp[] = array('v' => (string) $r['PersonName']);
$temp[] = array('v' => (string) $r['start']);
$temp[] = array('v' => (string) $r['end']);
$rows[] = array('c' => $temp);}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["timeline"]});
google.setOnLoadCallback(drawChart);
<!--Load the Ajax API-->
function drawChart() {
var container = document.getElementById('example3.1');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
var data = "" google.visualization.DataTable(<?php echo json_encode($table, JSON_NUMERIC_CHECK); ?>);
var options = {
title: 'Progress',
is3D: true
var options = {
timeline: { colorByRowLabel: true }
};
chart.draw(dataTable, options);
}
</script>
</head>
<body>
<div id="timeline" style="height: 180px;"></div>
</body>
</html>