1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $array_months=["01" => "Janvier","02" => "Février","03" => "Mars","04" => "Avril","05" => "Mai","06" => "Juin","07" => "Juillet","08" => "Août","09" => "Septembre","10" => "Octobre","11" => "Novembre","12" => "Décembre"];
$sql = " SELECT date_cotisation,SUM(total_cotisation) as total,month(date_cotisation) as mois FROM cotisation group BY year(date_cotisation),month(date_cotisation) ORDER BY date_cotisation";
$stmt_cotisations = $bdd_user->prepare($sql);
} catch(PDOException $e) {echo 'Erreur: '.$sql . "<br>" . $e->getMessage();}
$stmt_cotisations->execute(array());
while ($cotisations=$stmt_cotisations->fetch()) {
// Mois de l'array months
echo $array_months[date("m", strtotime($cotisations['date_cotisation']))]
// Année
echo date("Y", strtotime($cotisations['date_cotisation']));
//Somme
echo $cotisations['total'].'<br>';
} |
Partager