http://www.davisworthing.co.uk/graphs_monthly.php
plz can someone help me
<?php
include ('../../../utils/db_ro_details.php');
// Standard Source view option check
function check_sourceview () {
global $SITE;
if (isset($_GET['view']) && $_GET['view'] == 'sce') {
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/plain');
header('Accept-Ranges: bytes');
header("Content-Length: $download_size");
header('Connection: close');
readfile($filenameReal);
exit;
}
}
// Just list the PHP source?
check_sourceview();
// get the input parameters
if (isset($_GET["m"])) {
$month = intval($_GET["m"]);
} else {
die("No 'm' parameter supplied");
}
if ($month == "") {
die("Invalid 'm' parameter supplied");
}
// get the input parameters
if (isset($_GET["y"])) {
$year = intval($_GET["y"]);
} else {
die("No 'y' parameter supplied");
}
if ($year == "") {
die("Invalid 'y' parameter supplied");
}
// Connect to the database
$con=@mysqli_connect($dbhost,$dbuser,$dbpassword);
if (!$con) { echo "failed to connect to the database server"; exit(); }
if (!mysqli_select_db($database,$con)) { echo "Failed to connect to the database on the server"; exit(); }
#
# The db querys
#
//$result = $mysqlii->query("SET time_zone='+10:00'");
//if (!$result) { die("ERROR - TZ Statement"); }
$query = "SELECT MAX(MaxTemp), MIN(MinTemp), AVG(AvgTemp), MAX(HighHum), MIN(LowHum), SUM(TotRainFall), MAX(HighWindGust), SUM(TotWindRun), MIN(MinPress), MAX(MaxPress), MAX(HighSolarRad), SUM(HoursSun), MAX(HighAvgWSpeed), ROUND(AVG(DomWindDir),0) FROM Daydata WHERE Year(LogDate) = ".$year." and Month(LogDate) = ".$month."";
$result = mysqli_query($query);
if (!$result) { printf ("ERROR - Bad Select Statement"); exit; }
while($row = mysqli_fetch_row($result)) {
$TMaxM = (float)$row[0];
$TMinM = (float)$row[1];
$TAvgM = number_format((float)$row[2],1);
$HMaxM = (float)$row[3];
$HMinM = (float)$row[4];
$PTotM = (float)$row[5];
$VMaxM = (float)$row[6];
$VTotM = (float)$row[7];
$PMaxM = (float)$row[8];
$PMinM = (float)$row[9];
$SMaxM = (float)$row[10];
$STotM = (float)$row[11];
$WMaxM = (float)$row[12];
$WDirM = (float)$row[13];
}
$query = "SELECT UNIX_TIMESTAMP(LogDate) AS LogDate, MaxTemp, MinTemp, AvgTemp, HighHum, LowHum, TotRainFall, HighWindGust, TotWindRun, MinPress, MaxPress, HighSolarRad, HoursSun, HighAvgWSpeed, DomWindDir FROM Daydata WHERE Year(LogDate) = ".$year." and Month(LogDate) = ".$month." ORDER BY LogDate ASC";
//$query = "SELECT UNIX_TIMESTAMP(LogDate) AS LogDate, MaxTemp, MinTemp, AvgTemp FROM Daydata WHERE LogDate >= DATE_FORMAT(CURDATE() - INTERVAL " . $interval ." MONTH, '%Y-%m-%d') ORDER BY LogDate ASC";
$result = mysqli_query($query);
if (!$result) { printf ("ERROR - Bad Select Statement"); exit; }
// import the rows and put the data into arrays
while($row = mysqli_fetch_row($result)) {
$title[] = $row[0];
$TMax[] = (float)$row[1];
$TMin[] = (float)$row[2];
$TAvg[] = (float)$row[3];
$HMax[] = (float)$row[4];
$HMin[] = (float)$row[5];
$PTot[] = (float)$row[6];
$VMax[] = (float)$row[7];
$VTot[] = (float)$row[8];
$PMax[] = (float)$row[9];
$PMin[] = (float)$row[10];
$SMax[] = (float)$row[11];
$STot[] = (float)$row[12];
$WMax[] = (float)$row[13];
$WDDir[] = (float)$row[14];
}
// put into a single array
// Have to add an offset of 10 minutes to the start-date for some reason?!
//$rows =array(($title[0]+6000) * 1000, 'tmin' => $TMin, 'tmax' => $TMax, 'tavg' => $TAvg, 'hmin' => $HMin, 'hmax' => $HMax, 'rain' => $PTot, 'windr' => $VMax, 'windt' => $VTot, 'pmin' => $PMin, 'pmax' => $PMax,
// 'tminM' => $TMinM, 'tmaxM' =>$TMaxM, 'tavgM' =>$TAvgM, 'hmaxM' =>$HMaxM, 'hminM' =>$HMinM, 'rainM' =>$PTotM, 'windrM' => $VMaxM, 'windtM' => $VTotM, 'pminM' => $PMinM, 'pmaxM' => $PMaxM, 'smax' => $SMax, 'stot' => $STot, 'smaxM' => $SMaxM, 'stotM' => $STotM, 'wmaxM' => $WMaxM, 'wmax' => $WMax, 'wddir' => $WDDir, 'wdirM' => $WDirM);
$rows =array((($title[0]+86400)* 1000), 'tmin' => $TMin, 'tmax' => $TMax, 'tavg' => $TAvg, 'hmin' => $HMin, 'hmax' => $HMax, 'rain' => $PTot, 'windr' => $VMax, 'windt' => $VTot, 'pmin' => $PMin, 'pmax' => $PMax,
'tminM' => $TMinM, 'tmaxM' =>$TMaxM, 'tavgM' =>$TAvgM, 'hmaxM' =>$HMaxM, 'hminM' =>$HMinM, 'rainM' =>$PTotM, 'windrM' => $VMaxM, 'windtM' => $VTotM, 'pminM' => $PMinM, 'pmaxM' => $PMaxM, 'smax' => $SMax, 'stot' => $STot, 'smaxM' => $SMaxM, 'stotM' => $STotM, 'wmaxM' => $WMaxM, 'wmax' => $WMax, 'wddir' => $WDDir, 'wdirM' => $WDirM);
header("Content-type: text/json");
echo json_encode($rows);
?>