Bonjour,
Dans une page PHP qui traite une requête ajax, je suis obligé de faire d'autres instructions "echo" autre que celle principale devant servir à récupérer le résultat dans la fonction Javascript appelante.
Le problème , je suis obligé de faire un autre echo pour sur une boucle à l'intérieur.
Je vous donne ici le code PHP qui traite la requête Ajax:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php include('fonctions.php'); connect(); $sql_mod_chapt='select Num_compte,intitule_compte,nature_compte,C.id_chapitre,designation_chapitre from comptes C,chapitres Ch where C.id_chapitre=Ch.id_chapitre and Num_compte="'.$numerocompte.'"'; $result_mod_chapt=mysql_query($sql_mod_chapt) or die ('Erreur SQL !'.$sql_mod_chapt.'<br />'.mysql_error()); $nb_mod_chapt = mysql_num_rows($result_mod_chapt); while($row_mod_chapt=mysql_fetch_array($result_mod_chapt)) { echo '<tr align="center"> <td width=50%><input type="text" name="Num_compte_res" id="Num_compte_res" size="15" value="'.$row_mod_chapt['Num_compte'].'" /> <input type="hidden" name="numerocompte" id="numerocompte" size="15" value="'.$numerocompte.'" /> </td> <td width=50%><input type="text" name="intitule_compte" id="intitule_compte" size="40" value="'.$row_mod_chapt['intitule_compte'].'" /></td> <td width=50%><input type="text" name="nature_compte" id="nature_compte" size="20" value="'.$row_mod_chapt['nature_compte'].'" /></td> <td width=50%><select name="chapitre" id="chapitre"> <option value="'.$row_mod_chapt['id_chapitre'].'" />'.$row_mod_chapt['designation_chapitre'].'</option>'; $sql_chapt='select id_chapitre,designation_chapitre from chapitres where id_chapitre not in('.$row_mod_chapt['id_chapitre'].')'; $result_chapt=mysql_query($sql_chapt) or die ('Erreur SQL !'.$sql_chapt.'<br />'.mysql_error()); $nb_chapt = mysql_num_rows($result_chapt); while($row_chapt=mysql_fetch_array($result_chapt)) { echo '<option value="'.$row_chapt['id_chapitre'].'">'.$row_chapt['designation_chapitre'].'</option>'; } echo '</select></td> </tr>'; } ?>
Comment je pourrai faire pour renvoyer cette requête avec un seul "echo" de manière à récupérer le résultat sous forme de "ResponseText".
Merci de vos solutions.
Cordialement.
Partager