requete sql dans une bouble for
bonjour, je veux exécuter une requête dans une boucle for mais cela ne fonctionne pas. voici ma code php , si j'essaie de d’afficher les resultat de ma requete je voici que ma variable axe est attribuer a la dernière valeur du boucle
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $axe=$_POST['axe'];
for($i=0;$i<$nbre_axe;$i++)
{
// echo $axe[$i];
$sql="SELECT distinct
sextra.num_ordre,s.nom AS Nom, f.facnumber, sextra.s_gps,sextra.s_gps1,sextra.photo_facade,sextra.c_ag,f.total_ttc,(select max(date_delivery) from llx_livraison where fk_soc = s.rowid) as date_dist,(select 'oui' from echeances where ref = f.facnumber )
FROM llx_societe AS s JOIN llx_societe_extrafields AS sextra ON s.rowid = sextra.fk_object JOIN llx_facture AS f ON s.rowid = f.fk_soc JOIN llx_c_typent AS c ON s.fk_typent = c.id
where (s.rowid<>3025 and s.rowid<>3026 and f.paye=0 and f.rowid not in (select rowid from llx_facture as f where f.en_cours = 2)
and s.rowid not in (select fk_soc from llx_actioncomm where fk_action = 53 or fk_action = 54)
and f.facnumber not in (select num_ordre from echeances) and s.fk_departement = 662
and sextra.s_gps is not null and sextra.s_gps <> 1 and sextra.s_gps <> '' and sextra.axe='$axe[$i]' )
or (f.facnumber in (select num_ordre from echeances where paye = 0 and date_echeance <= NOW()))
order by `num_ordre` Asc and sextra.axe='$axe[$i]'";
}
//and (sextra.nb_relance <5 or sextra.nb_relance is null)
$res=mysql_query($sql); |
merci d'avance