0) { ?> query("SELECT * FROM chateau WHERE heure='06:00:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC"); $result_vol_22 = $connexion->query("SELECT * FROM chateau WHERE heure='22: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_vol_6[$while_date] = 'null'; $tab_vol_22[$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_vol_6->fetch()) { $tab_vol_6[$fetch['date']] = $fetch['compteur_impulsion']; } while($fetch = $result_vol_22->fetch()) { $tab_vol_22[$fetch['date']] = $fetch['compteur_impulsion']; } $s_vol_6 = ''; $s_vol_22= ''; $volmin = 100; $volmax = 0; $voltot = 0; $while_date = $date1; for($i = 0; $i < count($tab_vol_6); $i++) { if(isset($tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]) && $tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] != 'null' && $tab_vol_6[$while_date] != 'null') { $vol = ($tab_vol_6[$while_date]-$tab_vol_22[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]); // recherche mini et Maxi calcul total if ($vol<$volmin) $volmin = $vol; if ($vol>$volmax) $volmax = $vol; $voltot = $voltot + $vol; $s_vol_6 = $s_vol_6.$vol.','; } else $s_vol_6 = $s_vol_6.'null,'; $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); } $while_date = $date1; for($i = 0; $i < count($tab_vol_22); $i++) { if($tab_vol_22[$while_date] != 'null' && $tab_vol_6[$while_date] != 'null') { $vol = ($tab_vol_22[$while_date]-$tab_vol_6[$while_date]); // recherche mini et Maxi calcul total if ($vol<$volmin) $volmin = $vol; if ($vol>$volmax) $volmax = $vol; $voltot = $voltot + $vol; $s_vol_22 = $s_vol_22.$vol.','; } else $s_vol_22 = $s_vol_22.'null,'; $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=$voltot/($Nbjours); // moyenne par jour ?>
Du au (format ex.: 2014-05-27)