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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| $requete="SELECT t_clt.k_clt, nom, prenom, mail, k_commande, t_commandes.paie_des_c_fr
FROM t_commandes, t_clt
WHERE t_clt.k_clt = t_commandes.k_clt
AND etat = 'nouvelle'
AND STATUS = 'finalisee'";
$result= mysql_query($requete);
if(!$result)
{
echo "Lecture impossible";
}
else
{
$nbcol=mysql_num_fields($result);
$nbemail=mysql_num_rows($result);
echo "<h3> Tous nos e-mail enregistres</h3>";
echo "<h4> Il y a $nbemail nouvelles commandes enregistre </h4>";
echo "<table border=\"1\"><tbody>";
echo "<tr><th>No client</th> <th>Nom</th> <th>Prenom</th> <th>Mail</th><th>No commande</th><th>Moyen de paiement</th></tr>";
while($ligne=mysql_fetch_array($result,MYSQL_NUM))
{
echo "<tr>";
foreach($ligne as $valeur)
{
echo "<td> $valeur </td>";
}
echo "</tr>";
}
echo "</tbody></table>";
}
mysql_free_result($result);
$dest = "";
$requete2="select mail from t_commandes, t_clt where t_clt.k_clt = t_commandes.k_clt and etat='nouvelle' and status='finalisee'";
$exe = mysql_query($requete2);
$i=0;
while($dest=mysql_fetch_array($exe,MYSQL_NUM))
{
echo "<tr>";
foreach($dest as $mail)
{
echo "<td> $mail <br></td>";
}
$destinataires[$i]=$mail;
$i++;
echo "</tr>";
}
echo "</tbody></table>";
foreach ($destinataires as $cle=>$val){
echo 'num : '.$cle.' dest : '.$val.'<br/>';
}
$i=0; // on repasse $i à 0 pour parcourir $destinataires
foreach($destinataires as $cle=>$dest){
if(mail($dest,"FBI Distribution: votre commande No ", $text, $headers)){
echo "Envoi reussi a $dest";
}
else{
echo "Echec envoi a $dest";
}
}
?> |
Partager