I want to create a Flot graph that have on x-axis date values. I don't want to write manually the date values so I stored them in database like TIMESTAMP values. The connection to database is like:
<?php
$pdo = new PDO('mysql:host=example.com; dbname=database', 'user', 'password')
?>
The javascript code looks like:
var graphData = [ {
// first graphic
data: [ [(new Date("2006-06-12 19:13:37")).getTime(), 600], [(new Date("2006-06-21 19:13:37")).getTime(), 550], [(new Date("2006-07-1 19:13:37")).getTime(), 600]],
color: '#77b7c5',
points: { radius: 4, fillColor: '#77b7c5' }
}, {
//the second graphic
data: [[(new Date("2006-06-11 19:13:37")).getTime(), 3210.196] , [(new Date("2006-07-3 19:13:37")).getTime(), 3310.196], [(new Date("2006-07-23 19:13:37")).getTime(),3875.422]],
color: 'red'
}
];
I want to get those date values directly from my database and to create the graphic I use JavaScript. I know that is more secure to work with database in php and I don't know how I can display the flot graphic using values from database. Any ideas?