1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
// REQUETE 1 : chercher les prestataires et les regrouper par les 3 premiere lettres et compter le nombre de voyance gratuite
$query = "SELECT IF(customers_from LIKE '%1st%','1st',customers_from) AS Origin,
COUNT(*) AS effectif_vg
FROM customers
WHERE customers_from NOT LIKE '<%'
" . $condition . "
GROUP BY Origin ";
$result_vg = mysql_query($query) ;
while ($row = mysql_fetch_array($result_vg))
{
// REQUETE 2 : REQUETE QUI VA RECUPERER LES DONNES DE VG, NB DE COMMANDES, CA, MMC
$query_produit =
" SELECT
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 customers_from LIKE '%{$row['Origin']}%' " . $condition . "
";
if ($row['Origin'] == '') {
$query_produit = " SELECT
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 customers_from = '' " . $condition . "
";
}
$result = mysql_query($query_produit) ;
while ($row1 = mysql_fetch_array($result))
{
?>
<tr>
<td style="background-color:#CCCCCC;"> </td>
<td style="text-align:center;"> <?php echo $row['Origin'] ?> </td> |
Partager