comment eviter de faire 2 fois la meme requete
J'ai une page qui affiche les resultats d'un requete mais dans deux "Div" differente. Une pour les participants et l'autre pour le detail des points.
J'effectue donc deux boucle.
Code:
1 2 3 4 5 6
|
$sql = ...
$reponse1 = mysql_query($sql) or die (mysql_error());
$reponse2 = mysql_query($sql) or die (mysql_error()); |
Ma premiere Div:
Code:
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
|
<Div class="style12" align="left">
<table class="style16">
<?php
while ($donnees = mysql_fetch_array($reponse1))
{
static $a=1 ;
?>
<tr>
<td width="110" align="center"><?php echo $a++ ; ?>.</td>
<td width="120" align="center"><?php echo htmlentities($donnees['Nom']); ?></td>
<td width="120" align="center"><?php echo htmlentities($donnees['Prenom']); ?></td>
<td width="110" align="center"><?php echo $donnees['Total']; ?></td>
</tr>
<?php
}
?>
</table>
</Div> |
Et la deuxieme Div:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
<?php
while ($donnees = mysql_fetch_array($reponse2))
{
?>
<Div>
<table width="100%" height="100%">
<tr><td><?php echo htmlentities($donnees['Joueur1']); ?></td><td align="right"><?php echo $donnees['ST1']; ?></td></tr>
<tr><td><?php echo htmlentities($donnees['Joueur2']); ?></td><td align="right"><?php echo $donnees['ST2']; ?></td></tr>
<tr><td><?php echo htmlentities($donnees['Joueur3']); ?></td><td align="right"><?php echo $donnees['ST3']; ?></td></tr>
<tr><td><?php echo htmlentities($donnees['Joueur4']); ?></td><td align="right"><?php echo $donnees['ST4']; ?></td></tr>
<tr><td><?php echo htmlentities($donnees['Joueur5']); ?></td><td align="right"><?php echo $donnees['ST5']; ?></td></tr>
</table>
</Div> |
Ma question est comment faire pour faire deux fois la meme boucle (en prenant des infos differentes) sans executer deux fois la meme requete ?
PS: il est impossible de separer la requete en deux car il y a des calculs necessaire pour les deux affichages...