dispatcher un résultat sql selon le mois..
Bien le bonjour, j'ai un petit soucis, à mon avis c plus un problème de logique..
Je vous explique:
Je veux afficher les la quantité total de produits et ensuite dans un tableau html, dispatcher cette quantité selon les mois.
Exemple:
produit || quantité || janvier || février || mars ect ....
produit x || 6 || 4 || 2 || 0 et que des 0 pour les autres moi
quantité total= 6 dont 4 en janvier et 2 en février
Moi pour le moment ca m'affiche qtté total = 6 mais en janvier = 6 et les autres mois 0 .. Ca me dispatche pas la qtité de produit selon les mois..
Mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $sql = "SELECT date_commande,
CONCAT(produits.nom, ' ', produits.poids, ' ', produits.parfum) AS article,
SUM(quantite - cadeau) AS quantite,
SUM(cadeau) AS cadeau,
MONTH( date_commande ) AS date,
commandes_detail.id_produit
FROM commandes_detail
LEFT JOIN commandes ON commandes_detail.id_commande = commandes.id
LEFT JOIN produits ON commandes_detail.id_produit = produits.id
WHERE statut = 100
GROUP BY id_produit
ORDER BY article";
sql_mysql_query($sql);] |
et coté php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<td align="right"><?php if ($row->date==1) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==2) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==3) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==4) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==5) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==6) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==7) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==8) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==9) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==10) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==11) echo $row->quantite; ?> </td>
<td align="right"><?php if ($row->date==12) echo $row->quantite; ?> </td> |
date==1 >> janvier ect...
Comment dois je faire pour résoudre mon problème et que la quantité soit réparti correctement selon le mois ???