function getColour($temp, $online) {
if ($online == "1") {
$temp = (float)$temp;
if (-40<=$temp and $temp<-20) {
$col = "C1";
} elseif (-20<=$temp and $temp<-15) {
$col = "C2";
} elseif (-15<=$temp and $temp<-10) {
$col = "C3";
} elseif (-10<=$temp and $temp<-5) {
$col = "C4";
}elseif (-5<=$temp and $temp<-2) {
$col = "C5";
}elseif (-2<=$temp and $temp<2) {
$col = "C6";
}elseif (2<=$temp and $temp<5) {
$col = "C7";
}elseif (5<=$temp and $temp<8) {
$col = "C8";
}elseif (8<=$temp and $temp<11) {
$col = "C9";
}elseif (11<=$temp and $temp<14) {
$col = "C10";
}elseif (14<=$temp and $temp<17) {
$col = "C11";
}elseif (17<=$temp and $temp<20) {
$col = "C12";
}elseif (20<=$temp and $temp<23) {
$col = "C13";
}elseif (23<=$temp and $temp<26) {
$col = "C14";
}elseif (26<=$temp and $temp<28) {
$col = "C15";
}elseif (28<=$temp and $temp<30) {
$col = "C16";
}elseif (30<=$temp and $temp<33) {
$col = "C17";
}elseif (33<=$temp and $temp<36) {
$col = "C18";
}elseif (36<=$temp and $temp<38) {
$col = "C19";
}elseif (38<=$temp and $temp<40) {
$col = "C20";
}elseif (40<=$temp and $temp<45) {
$col = "C21";
}
} else {
$col = "C0";
}
return $col;
}
function getTemp($online, $temp) {
if ($online == "0") {
$temp = "--";
} else {
$temp = $temp;
}
return $temp;
}
?>
function getTab() {
$valueArr = array();
$mysqli = new mysqli("localhost", "c1meteobibbiena", "Mamminamia@27", "c1meteobibbiena");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$query = 'SELECT temp as max, name, id FROM rete_meteo WHERE temp = (SELECT max(temp) FROM rete_meteo WHERE online="1" AND blocco="0")';
if ($result = $mysqli->query($query)) {
/* print html loop */
$row = $result->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query2 = 'SELECT temp as min, name, id FROM rete_meteo WHERE temp = (SELECT min(temp) FROM rete_meteo WHERE online="1" AND blocco="0")';
if ($result2 = $mysqli->query($query2)) {
/* print html loop */
$row = $result2->fetch_assoc();
$valueArr[] = $row["min"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query3 = 'SELECT windsp as max, name, id FROM rete_meteo WHERE windsp = (SELECT max(windsp) FROM rete_meteo WHERE online="1" AND blocco="0")';
if ($result3 = $mysqli->query($query3)) {
/* print html loop */
$row = $result3->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query4 = 'SELECT rr as max, name, id FROM rete_meteo WHERE rr = (SELECT max(rr) FROM rete_meteo WHERE online="1" AND blocco="0")';
if ($result4 = $mysqli->query($query4)) {
/* print html loop */
$row = $result4->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query5 = 'SELECT hitemp as max, name, id FROM rete_meteo WHERE hitemp = (SELECT max(hitemp) FROM rete_meteo WHERE online="1" AND hitemp >= -25 AND hitemp <= 45 AND blocco="0")';
if ($result5 = $mysqli->query($query5)) {
/* print html loop */
$row = $result5->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query6 = 'SELECT lowtemp as min, name, id FROM rete_meteo WHERE lowtemp = (SELECT min(lowtemp) FROM rete_meteo WHERE online="1" AND lowtemp >= -25 AND lowtemp <= 45 AND blocco="0")';
if ($result6 = $mysqli->query($query6)) {
/* print html loop */
$row = $result6->fetch_assoc();
$valueArr[] = $row["min"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query7 = 'SELECT hiwind as max, name, id FROM rete_meteo WHERE hiwind = (SELECT max(hiwind) FROM rete_meteo WHERE online="1" AND blocco="0")';
if ($result7 = $mysqli->query($query7)) {
/* print html loop */
$row = $result7->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
$query8 = 'SELECT dayrain as max, name, id FROM rete_meteo WHERE dayrain = (SELECT max(dayrain) FROM rete_meteo WHERE online="1" AND dayrain >= 0 AND dayrain <= 400 AND name != "Stroppiello" AND blocco="0")';
if ($result8 = $mysqli->query($query8)) {
/* print html loop */
$row = $result8->fetch_assoc();
$valueArr[] = $row["max"];
$valueArr[] = $row["name"];
$valueArr[] = $row["id"];
}
/* free result set */
$result->free();
$result2->free();
$result3->free();
$result4->free();
$result5->free();
$result6->free();
$result7->free();
$result8->free();
/* close connection */
$mysqli->close();
return $valueArr;
}
?>