|
|
|
|
Bonjour,
j'ai fait deu requete différente qui ce lie mais j'ai un problème d'affichage car un moment j'ai un resultat null donc sa m'affiche pas et je perd une place donc c'est un autre résultat qui me prend la place du null j'aimerai savoir comment fair pour que sa m'affiche '0'
je vous montre mes deu requete
<?php
$query_vg ="
SELECT substr(customers_from, 1, 3) AS Origin,
COUNT(*) AS effectif_vg
FROM customers
GROUP BY Origin ";
$result_vg = mysql_query($query_vg) ;
// requete pour chaque ligne "client" (ayant une facture)
$query = " SELECT substr(customers_from, 1, 3) AS Origin,
COUNT(DISTINCT cu.customers_id) AS effectif, count(co.commandes_status) AS command,
AVG(co.commandes_montant) AS Mmc
FROM customers cu
INNER JOIN commandes co
ON cu.customers_id=co.customers_id
WHERE co.commandes_status='1'
GROUP BY Origin ";
$result = mysql_query($query) ;
while ($row1 = mysql_fetch_array($result_vg) and $row = mysql_fetch_array($result) )
{
?>
<tr>
<td style="background-color:#CCCCCC;"> </td>
<td style="text-align:center;"> <?php echo $row1['Origin'] ?> </td>
<td style="text-align:center;"> <?php echo $row1['effectif_vg'] ?> </td>
<td style="text-align:center;"> <?php echo $row['command'] ?> </td>
<td style="text-align:center;"> <?php echo round(($row['command']*$row['Mmc'])) ?> euro</td>
<td style="text-align:center;"> <?php echo round($row['Mmc'] ,2)?> </td>
</tr>
<?php
}
?>
Configuration: Windows XP Firefox 3.0.10
Je te remerci j'ai fait comme sa
$query = " SELECT substr(customers_from, 1, 3) AS Origin,
COUNT(DISTINCT cu.customers_id) AS effectif, ifnull( co.commandes_status , '0') ,count(co.commandes_status) AS command,
AVG(co.commandes_montant) AS Mmc
FROM customers cu
INNER JOIN commandes co
ON cu.customers_id=co.customers_id
WHERE co.commandes_status='1'
GROUP BY Origin ";
Mais sa marche pas je sais pas si c'est parce que je le fai mal?? |
Bonjour,
$query_vg ="
SELECT substr(customers_from, 1, 3) AS Origin,
COUNT(*) AS effectif_vg
FROM customers
GROUP BY Origin ";
$result_vg = mysql_query($query_vg) ;
// requete pour chaque ligne "client" (ayant une facture)
$query = " SELECT substr(customers_from, 1, 3) AS Origin,
COUNT(DISTINCT cu.customers_id) AS effectif ,count(co.commandes_status) AS command,
AVG(co.commandes_montant) AS Mmc
FROM customers cu
INNER JOIN commandes co
ON cu.customers_id=co.customers_id
WHERE co.commandes_status='1'
GROUP BY Origin ";
$result = mysql_query($query) ;
while ($row1 = mysql_fetch_array($result_vg) and $row = mysql_fetch_array($result) )
{
if($row['command'] == '0' )
{ $row['command'] .= 'zero';
?>
<tr>
<td style="background-color:#CCCCCC;"> </td>
<td style="text-align:center;"> <?php echo $row1['Origin'] ?> </td>
<td style="text-align:center;"> <?php echo $row1['effectif_vg'] ?> </td>
<td style="text-align:center;"> <?php echo $row['command'] ?> </td>
<td style="text-align:center;"> <?php echo round(($row['command']*$row['Mmc'])) ?> euro</td>
<td style="text-align:center;"> <?php echo round($row['Mmc'] ,2)?> </td>
</tr>
<?php
} }
?> |
Bonjours, j'ai toujours ce problème qui ne ce résolut pas
co.commandes_status='1' j'en ai besoin car je doi faire mes calcules vis a vie des personne qui on commandé mais j'aimerai bien aussi sortire toutes les personne inscrite mais qui n'on pas forcément commandé car dans mon tableau sa marche bien mais sa n'affiche pas quant il y a 0 commande, C.A et Mmc ce que j'aimerai. Ma requette est comme sa: $query_produit = " SELECT substr(customers_from, 1, 3) AS Origin, COUNT(DISTINCT cu.customers_id) AS effectif, count(co.commandes_status) AS command, AVG(co.commandes_montant) AS Mmc FROM customers cu INNER JOIN commandes co ON cu.customers_id=co.customers_id WHERE co.commandes_status='1' and substr(customers_from , 1 , 3) ='".$row['Origin']."' AND customers_date_inscription BETWEEN '2009-04-01' AND '2009-04-30' GROUP BY Origin "; |