Bonjour à tous,

J'ai une petite question pour améliorer la rapidité d'affichage.
J'ai une requete qui va chercher environ 5000 données dans une table et je la met en forme dans un tableau. Mais à chaque ligne je réalise de nouveau une requête pour avoir des informations complèmentaires dans une autre table. Comment faire pour améliorer tout cela ?

Voici le code
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
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
68
69
70
71
72
73
74
 
<?php
	//Requete sélection des adherents
	$req_adh = 'SELECT id_adh, nom_adh, prenom_adh, tel_adh, etat_adh FROM adherents ORDER BY id_adh ASC';
	$res_adh = mysql_query($req_adh);
?>
	<table align="center" width="100%" id="table_adh">
		<thead>
		<tr>
			<th>N&deg; Adh</th>
			<th>Nom</th>
			<th>Pr&eacute;nom</th>
			<th>T&eacute;l&eacute;phone</th>
			<th>Date Inscription</th>
			<th>Dur&eacute;e</th>
			<th>Montant</th>
			<th>Date de fin</th>
			<th>Etat</th>
			<th>&nbsp;</th>
		</tr>
		</thead>
		<tbody>
 
		<?php
		while($adherent = mysql_fetch_array($res_adh))
		{
		?>
		<tr align="center">
			<td><?php echo $adherent['id_adh'];?></td>
			<td><a href="?page=detail_adh&id=<?php echo $adherent['id_adh'];?>" class="action"><?php echo $adherent['nom_adh'];?></a></td>
			<td><a href="?page=detail_adh&id=<?php echo $adherent['id_adh'];?>" class="action"><?php echo $adherent['prenom_adh'];?></a></td>
			<td><?php echo $adherent['tel_adh'];?></td>
			<?php
			$sql_fact = 'SELECT DISTINCT id_fact, date_fact, duree_fact, montant_fact, id_adh_fact FROM facture WHERE id_adh_fact='.$adherent['id_adh'].' ORDER BY date_fact DESC LIMIT 1'; 
			$req_fact = mysql_query($sql_fact) or die('Erreur SQL !<br>'.$sql_fact.'<br>'.mysql_error());
 
			if(mysql_num_rows($req_fact)>0)
			{//Si on a un résultat
				while($facture = mysql_fetch_assoc($req_fact))
				{
					$date_facture_fr = explode('-',$facture['date_fact']);
 
					echo "<td>".$date_facture_fr[2].'/'.$date_facture_fr[1].'/'.$date_facture_fr[0]."</td>";
					echo "<td>".$facture['duree_fact']."</td>";
					echo "<td>".$facture['montant_fact']." &euro;</td>";
 
					$date_fin =  mktime(0,0,0, $date_facture_fr[1] + $facture['duree_fact'], $date_facture_fr[2], $date_facture_fr[0]);
					$date_fin_fr=date('d/m/Y',$date_fin);
 
					echo "<td>".$date_fin_fr."</td>";
				} 
			}
			else
			{
				echo "<td>0000/00/00</td>";
				echo "<td>0</td>";
				echo "<td>0</td>";			
				echo "<td>0000/00/00</td>";
			}
			?>
			<td><?php echo $adherent['etat_adh'];?></td>
			<td align="center">
				<a href="pages/adherents/modif_rapid_adherent.php?id=<?php echo $adherent['id_adh'];?>" rel="action" title="Modifier l'adh&eacute;rent rapidement">
				<span class="ui-state-default ui-corner-all ui-icon ui-icon-pencil"></span></a>
			</td>
		</tr>
		<?php
		}
		?>
		</tbody>
	</table>
<?php
}//Vérification qu'une session existe bien
?>