SELECT MIN(hchc) as min_hc2, MAX(hchc) as max_hc2,MIN(hchp) as min_hp2, MAX(hchp) as max_hp2 ,`date` as date_1 FROM $base_name GROUP BY `date`
$query = "SELECT ................"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $day = day($row['date_1']); $month = month($row['date_1']; $ind_hc[month($month['date_1'])][$day]=$row['max_hc2']-$row['min_hc2']; $ind_hp[month($month][$day]=$row['max_hp2']-$row['min_hp2']; } mysql_close($db);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionwhile($row = mysql_fetch_array($result)){ //on recupere le jour et le mois pour faire les indices du tableau $day = date('d',$row['date_1']); $month = date('m',$row['date_1']; $ind_hc[$month][$day]]=$row['max_hc2']-$row['min_hc2']; $ind_hp[$month][$day]=$row['max_hp2']-$row['min_hp2']; }
$MONTHS = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); $dimx=600; $dimy=400; $ind_hc=array(13,32); // 28 ???? SUELEMENT ?? $ind_hp=array(13,32); $ind_hc2=array(32); $ind_hp2=array(32); $A=substr($annee,2,2); $db = mysql_connect($url_sql, $log, $pass); // on se connecte à MySQL mysql_select_db($table_sql,$db); // on sélectionne la base // Extraction des valeurs MIN et MAX de HCHC et de HCHP $sql = "SELECT MIN(hchc) as min_hc2, MAX(hchc) as max_hc2,MIN(hchp) as min_hp2, MAX(hchp) as max_hp2 ,`date` as date_1 FROM $base_name GROUP BY `date`"; $result=mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)) { //on recupere le jour et le mois pour faire les indices du tableau // echo ' date : '.$row['date_1'].' '; $day = date('j', strtotime($row['date_1'])); $month= date('n', strtotime($row['date_1'])); // echo ' day : '.$day.' '; // echo 'month : '.$month.' '; $ind_hc[$month][$day] =$row['max_hc2']-$row['min_hc2']; $ind_hp[$month][$day]= $row['max_hp2']-$row['min_hp2']; } mysql_close($db); // on ferme la connexion à mysql for ($month=1;$month<13;$month++) { for ($day=1;$day<32;$day++) { // echo ' Day : '.$day.' Month : '.$month.' '; // echo 'Tab hc: '.$ind_hc[$month][$day].'Tab hp: '.$ind_hp[$month][$day].' '; if ($ind_hc[$month][$day] == "" || $ind_hp[$month][$day]=="") // des fois il n'y a pas de log pr ce jour ou le jour n'existe pas selon le mois { echo ' AAARGG : '; $ind_hc2[$day] =0; $ind_hp2[$day]=0; } else { $ind_hc2[$day]=$ind_hc[$month][$day]; $ind_hp2[$day]=$ind_hp[$month][$day]; } } $graph5 = new Graph($dimx,$dimy); // Creation du graphique $graph5->SetScale("linlin",0,60000,1,31); $graph5->title->Set("Index Menusel de ".$MONTHS[$month-1]." 20".$A ); $graph6 = new Graph($dimx,$dimy); // 05/02/09 Creation du graphique $graph6->SetScale("linlin",0,80000,1,31); // 05/02/09 $graph6->title->Set("Index Menusel Cumulé de ".$MONTHS[$month-1]." 20".$A ); // 05/02/09 $bar = new BarPlot($ind_hc2); $bar2 = new BarPlot($ind_hp2); $bar ->SetColor("green"); $bar->SetFillColor("green"); $bar2 ->SetColor("red"); $bar2->SetFillColor("red"); // $bar->SetLegend ("Index HC"); // Légende de la courbe // $bar2->SetLegend ("Index HP"); // Légende de la courbe $graph5 ->legend->Pos( 0.05,0.5,"right" ,"center"); // Posiiton de la légende $graph5 ->SetColor('#829FD9'); $graph6 ->legend->Pos( 0.05,0.5,"right" ,"center"); // 05/02/09 Posiiton de la légende $graph6 ->SetColor('#829FD9'); // 05/02/09 $bar->SetShadow(); $bar2->SetShadow(); $bar->value->SetAngle(90); $bar2->value->SetAngle(90); $bar->value-> Show(); $bar2->value-> Show(); $d= new GroupBarPlot (array($bar ,$bar2)); $accbar = new AccBarPlot(array($bar,$bar2)); // 05/02/09 $graph5->SetBackgroundGradient('blue:1.6','navy:1.6',GRAD_LEFT_REFLECTION,BGRAD_PLOT); $graph5->Add($d); $graph6->SetBackgroundGradient('blue:1.6','navy:1.6',GRAD_LEFT_REFLECTION,BGRAD_PLOT); $graph6->Add($accbar); // 05/02/09 // $A=substr($jour_a_aff,2,2); // sert à donner un nom aux graphique car des pb lors du chgt de date, ancien graph tjrs affiché et pas rechargé // $M=substr($jour_a_aff,5,2); // $J=substr($jour_a_aff,8,2); if (strlen($month)==1){$M="0".$month;} // Rajoute un Zero au chiffre des unités pr garder la meme lg de la string else{$M=$month;} $D=$A.$M; if ($IMN==1) { $graph5->Stroke("images/graph4_$D.png"); // Affichage echo ""; // 03/02/10 }//." "; if ($IMC==1) { $graph6->Stroke("images/graph5_$D.png"); // 05/02/09 Affichage echo ""; // 03/02/10 }//." "; } // 05/02/09 // } }
// Extraction des valeurs MIN et MAX de HCHC et de HCHP $sql = "SELECT MIN(hchc) as min_hc2, MAX(hchc) as max_hc2,MIN(hchp) as min_hp2, MAX(hchp) as max_hp2 ,`date` as date_1 FROM $base_name GROUP BY `date`"; $result=mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)) { //on recupere le jour et le mois pour faire les indices du tableau // echo ' date : '.$row['date_1'].' '; $day = date('j', strtotime($row['date_1'])); $month= date('n', strtotime($row['date_1'])); echo ' row : '.$row['min_hc2'].' - '.$row['max_hc2'].' - '.$row['min_hp2'].' - '.$row['max_hp2'].' '; echo 'day : '.$day.' '; echo 'month : '.$month.' '; $ind_hc[$month][$day] =$row['max_hc2']-$row['min_hc2']; $ind_hp[$month][$day]=$row['max_hp2']-$row['min_hp2']; }
print_r($ind_hc);