0) { ?> query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC"); // On effectue une requête pour récupérer les données $while_date = $date1; $s_date = ''; // On initialise while(strtotime($while_date) <= strtotime($date2)) { $tab_vol_6[$while_date] = 'null'; $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); } $while_datebis = $date1bis; while(strtotime($while_datebis) <= strtotime($date2)) { $s_date = $s_date.'"'.date("d/m/y", strtotime($while_datebis)).'",'; $while_datebis = date("Y-m-d", strtotime("+1 day", strtotime($while_datebis))); } while($fetch = $result_vol_6->fetch()) //On remplie tab_vol_6 avec les valeurs de la bdd { $tab_vol_6[$fetch['date']] = $fetch['volume']; } $s_vol_6 = ''; $volmin = 100; $volmax = 0; $voltot = 0; $Nbjours_V1=0; $while_date = $date1; for($i = 0; $i < count($tab_vol_6); $i++)//On remplie s_vol_6 des valeurs de la bdd pour highchart { if(isset($tab_vol_6[$while_date]) && $tab_vol_6[$while_date] != 'null' and $i != 0) { if($tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))] == 'null')//On vérifie que la valeur précédente éxiste if($tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))] != 'null') { $vol = $tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]; $Nbjours_V1++;//Compte le nombre de jours avec valeur } else $vol ='0'; else { $vol = $tab_vol_6[$while_date]-$tab_vol_6[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; $Nbjours_V1++;//Compte le nombre de jours avec valeur } $vol = round($vol, 2); if ($vol<$volmin) $volmin = $vol; if ($vol>$volmax) $volmax = $vol; $voltot = $voltot + $vol; $s_vol_6 = $s_vol_6.$vol.','; //On ajoute la valeur au tableau } else if ($i != 0) $s_vol_6 = $s_vol_6.'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 $result_pomp = $connexion->query("SELECT * FROM surpresseur WHERE heure='00:15:00' and date >= '".$date1."' and date <= '".$date2."' ORDER BY date, heure ASC"); $i = 0; while($fetch = $result_pomp->fetch()) //On remplie tab_pomp1 et tab_pomp2 avec les valeurs de la bdd { $tab_pomp1[$fetch['date']] = $fetch['horaire_pp1']; $tab_pomp2[$fetch['date']] = $fetch['horaire_pp2']; } $s_pomp1 = ''; $s_pomp2= ''; $vol_maxp1 = 0; $vol_minp1 = 100; $vol_totp1 = 0; $Nbjours_P1=0; $while_date = $date1; for($i = 0; $i < $Nbjours+1; $i++)//On remplie $s_pomp1 des valeurs de la bdd pour highchart { if(isset($tab_pomp1[$while_date]) && $tab_pomp1[$while_date] != 'null' and $i != 0) { if(!isset($tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]))//On vérifie que la valeur précédente éxiste if(isset($tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) { $vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]; $Nbjours_P1++;//Compte le nombre de jours avec valeur } else $vol ='0'; else { $vol = $tab_pomp1[$while_date]-$tab_pomp1[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; $Nbjours_P1++;//Compte le nombre de jours avec valeur } $vol = round($vol, 2); if ($vol<$vol_minp1) $vol_minp1 = $vol; if ($vol>$vol_maxp1) $vol_maxp1 = $vol; $vol_totp1 = $vol_totp1 + $vol; $s_pomp1 = $s_pomp1.$vol.','; //On ajoute la valeur au tableau } else if ($i != 0) $s_pomp1 = $s_pomp1.'null,'; $while_date = date("Y-m-d", strtotime("+1 day", strtotime($while_date))); } $vol_maxp2 = 0; $vol_minp2 = 100; $vol_totp2 = 0; $Nbjours_P2=0; $while_date = $date1; for($i = 0; $i < $Nbjours+1; $i++)//On remplie $s_pomp2 des valeurs de la bdd pour highchart { if(isset($tab_pomp2[$while_date]) && $tab_pomp2[$while_date] != 'null' and $i != 0) { if(!isset($tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]))//On vérifie que la valeur précédente éxiste if(isset($tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))])) { $vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-2 day", strtotime($while_date)))]; $Nbjours_P2++;//Compte le nombre de jours avec valeur } else $vol='0'; else { $vol = $tab_pomp2[$while_date]-$tab_pomp2[date("Y-m-d", strtotime("-1 day", strtotime($while_date)))]; $Nbjours_P2++;//Compte le nombre de jours avec valeur } $vol = round($vol, 2); if ($vol<$vol_minp2) $vol_minp2 = $vol; if ($vol>$vol_maxp2) $vol_maxp2 = $vol; $vol_totp2 = $vol_totp2 + $vol; $s_pomp2 = $s_pomp2.$vol.','; //On ajoute la valeur au tableau } else if ($i != 0) $s_pomp2 = $s_pomp2.'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; $vmoyp1=$vol_totp1/($Nbjours_P1); // moyenne par jour $vmoyp2=$vol_totp2/($Nbjours_P2); // moyenne par jour $vmoy=$voltot/($Nbjours_V1); // moyenne par jour ?>
Du au (format ex.: 2014-05-27)
".round($voltot, 2)." m³ -- Tmoy/jour = ".round($vmoy, 2)." m³ (".$Nbjours_V1."J) -- Tmin = ".round($volmin, 2)." m³ -- TMax = ".round($volmax, 2)." m³ --- "; } else echo 'Vous n\'êtes pas autorisé/connecté!'; include('foot.php'); ?>