Hello , i' trying to make a graph using the temperature data read by my arduino , These data are loaded in a database thanks to a php script, I'm trying to use this library http://www.ebrueggeman.com/ but i can't create my graph. Anyone could help me? The code i've written is this.
<?php
include("phpgraphlib.php");
$graph=new PHPGraphLib(500,400);
$hostname="******";
$username="*****";
$password="******";
$conn=mysql_connect($hostname,$username,$password);
if(!conn){
die("Error.");
exit();
}
echo("OK.");
mysql_select_db("domotica");
$data = array();
$sql="SELECT temp,COUNT(*) as 'count' FROM temp";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$temp = $row["temp"];
$count=$row["count"];
$data[$temp] = $count;
}
}
$graph->addData($data);
$graph->setTitle("Temperatura");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor("yellow");
$graph->setDataValues(true);
$graph->setDataValueColor("blue");
$graph->createGraph();
?>
The table is like this:
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| ID | int(11) | NO | PRI | NULL | auto_increment |
| temp | int(11) | NO | | NULL | |
+-------+---------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
Or if you use an other way to create graph for arduino i would be happy if you explain it to me. Thanks