New file |
0,0 → 1,45 |
<? |
include ("../connect.php"); |
|
$evenement_id = $_SESSION['observation']['evenement_id']; |
$commune_id = $_SESSION['observation']['commune_id']; |
$espece_id=$_SESSION['observation']['espece_id']; |
|
$req_dates = mysql_query("SELECT DATE_FORMAT(MESURE_DATE,'%d%m'), DATE_FORMAT(MESURE_DATE,'%Y') as ANNEE FROM MESURE,SEQUENCE". |
" where SEQUENCE.SEQUENCE_ID=MESURE.SEQUENCE_ID and". |
" EVENEMENT_ID=$evenement_id and ESPECE_ID=$espece_id". |
" AND MESURE_DATE!='0000-00-00'". |
" and STATION_ID=$commune_id". |
" order by ANNEE"); |
echo mysql_error(); |
$dates = array(); |
$lastannee = 0; |
$nbdates = 1; |
while ($obs = mysql_fetch_row($req_dates)) { |
$jour_crt = substr($obs[0],0,2); |
$mois_crt = substr($obs[0],2,2); |
$annee_crt = $obs[1]; |
if ($obs[1]!=$lastannee) { |
//on calcule la moyenne pour la commune précédente : |
if ($lastannee != 0) |
$dates[$lastannee] = $dates[$lastannee]/$nbdates; |
//on initialise les variables pour la nouvelle commune |
$nbdates = 1; |
$lastannee=$obs[1]; |
$dates[$lastannee] = mktime(0,0,0,$mois_crt,$jour_crt); |
} else { |
$nbdates++; |
$dates[$lastannee] += mktime(0,0,0,$mois_crt,$jour_crt); |
} |
} |
$dates[$lastannee] = $dates[$lastannee]/$nbdates; |
|
if (sizeof($dates)>0) { |
$dateMin = min ($dates); |
$dateMax = max ($dates); |
$nbDates = sizeof ($dates); |
} |
else { |
$erreurs[] = "Il n'y a pas encore de données cette année pour cette observation."; |
} |
?> |