0) { ?>
query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '" . $date1 . "' and date <= '" . $date2 . "' ORDER BY date, heure ASC"); $while_date = $date1; $s_date = ''; while (strtotime($while_date) <= strtotime($date2)) { $tab_amb[$while_date] = 'null'; $tab_col[$while_date] = 'null'; $s_date = $s_date . '"' . date("d/m/y", strtotime($while_date)) . '",'; $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); } while ($fetch = $result_temp->fetch()) { $tab_amb[$fetch['date']] = $fetch['temp_ambiante']; $tab_col[$fetch['date']] = $fetch['temp_colonne']; } $s_temp_amb = ''; $s_temp_col = ''; $temp_ambmin = 100; $temp_ambmax = 0; $temp_ambtot = 0; $temp_colmin = 100; $temp_colmax = 0; $temp_coltot = 0; $while_date = $date1; for ($i = 0; $i < count($tab_amb); $i++) { // recherche mini et Maxi calcul total $temp_amb = $tab_amb[$while_date]; $temp_col = $tab_col[$while_date]; if ($temp_amb < $temp_ambmin) $temp_ambmin = $temp_amb; if ($temp_amb > $temp_ambmax) $temp_ambmax = $temp_amb; if ($temp_col < $temp_colmin) $temp_colmin = $temp_col; if ($temp_col > $temp_colmax) $temp_colmax = $temp_col; $temp_ambtot += intval($temp_amb); $temp_coltot += intval($temp_col); $s_temp_amb .= $temp_amb . ','; $s_temp_col .= $temp_col . ','; $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); } // calcul du nombre de jours sur l'intervalle $TDfin = strtotime($date2); // conversion timestamp $TDDeb = strtotime($date1); $Nbjours = round(($TDfin - $TDDeb) / (60 * 60 * 24)); //division des secondes pour avoir les jours //$Nbjours = 31; // Affichage des données bilan sur la période; $vmoy_amb = $temp_ambtot / ($Nbjours); // moyenne par jour $vmoy_col = $temp_coltot / ($Nbjours); // moyenne par jour ?>