Subversion Repositories Sites.obs-saisons.fr

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 aurelien 1
<?
2
include ("../connect.php");
3
 
4
$evenement_id = $_SESSION['observation']['evenement_id'];
5
$commune_id = $_SESSION['observation']['commune_id'];
6
$espece_id=$_SESSION['observation']['espece_id'];
7
 
8
$req_dates = mysql_query("SELECT DATE_FORMAT(MESURE_DATE,'%d%m'), DATE_FORMAT(MESURE_DATE,'%Y') as ANNEE FROM MESURE,SEQUENCE".
9
	" where SEQUENCE.SEQUENCE_ID=MESURE.SEQUENCE_ID and".
10
	" EVENEMENT_ID=$evenement_id and ESPECE_ID=$espece_id".
11
	" AND MESURE_DATE!='0000-00-00'".
12
	" and STATION_ID=$commune_id".
13
	" order by ANNEE");
14
echo mysql_error();
15
$dates = array();
16
$lastannee = 0;
17
$nbdates = 1;
18
while ($obs = mysql_fetch_row($req_dates)) {
19
  $jour_crt = substr($obs[0],0,2);
20
  $mois_crt = substr($obs[0],2,2);
21
  $annee_crt = $obs[1];
22
  if ($obs[1]!=$lastannee) {
23
    //on calcule la moyenne pour la commune précédente :
24
    if ($lastannee != 0)
25
      $dates[$lastannee] = $dates[$lastannee]/$nbdates;
26
    //on initialise les variables pour la nouvelle commune
27
    $nbdates = 1;
28
    $lastannee=$obs[1];
29
    $dates[$lastannee] = mktime(0,0,0,$mois_crt,$jour_crt);
30
  } else {
31
    $nbdates++;
32
    $dates[$lastannee] += mktime(0,0,0,$mois_crt,$jour_crt);
33
  }
34
}
35
$dates[$lastannee] = $dates[$lastannee]/$nbdates;
36
 
37
if (sizeof($dates)>0) {
38
  $dateMin = min ($dates);
39
  $dateMax = max ($dates);
40
  $nbDates = sizeof ($dates);
41
}
42
else {
43
  $erreurs[] = "Il n'y a pas encore de données cette année pour cette observation.";
44
}
45
?>