JpGraph mysql ошибка. Данные базы данных не отображаются на графике
Мне нужна помощь в решении проблемы со скриптом Jpgraph, над которым я работаю. Я не могу получить данные из моей базы данных MySQL для отображения на линейном графике. Может кто-нибудь помочь мне в решении этой проблемы, пожалуйста? Я включил сценарий ниже.
Большое спасибо
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_line.php');
$host = "localhost";
$username = "test";
$password = "fuji12";
$database = "ems";
$connection=mysql_connect ($host, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$sql = "SELECT * FROM DHT22 WHERE MONTH(date) = MONTH(CURDATE()) ORDER BY date LIMIT 31";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
while($row = mysql_fetch_array($result)) {
$date=$row["date"];
$humd=$row["humdity"];
$temp=$row["temp"];
//add to data areray
$dataArray[$date]=$humd;
$dataArray2[$date]=$temp;
}
}
// Setup the graph
$graph = new Graph(550,450);
$graph->SetScale("intlin");
$theme_class=new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Daily Readings');
$graph->SetBox(false);
$graph->img->SetAntiAliasing();
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');
// Create the first line
$p1 = new LinePlot($dataArray[$date]);
$graph->Add($p1);
$p1->SetColor("#6495ED");
$p1->SetLegend('Temperature');
// Create the second line
$p2 = new LinePlot($dataArray2[$date]);
$graph->Add($p2);
$p2->SetColor("#B22222");
$p2->SetLegend('Humidity');
$graph->legend->SetFrameWeight(1);
// Output line
$graph->Add($p1);
$graph->Add($p2);
$graph->Stroke();
?>