Optimisation affichage d'un query
Bonjour à tous,
Je voudrais afficher pour chaque abonné les options qu'il posséde:
Pour cela j'ai une requête:
Code:
1 2
|
$rq_cpt3=odbc_do($conn,"SELECT DISTINCT E7B8ZC,DYEVZE from osm_option "); |
Je voudrais quelqu'chose du genre :
abone1 : option15,option16,option22,option05,
abone2 : option07,option16,option14,option03,
etc
J'ai reussi a arrivé à ce resultat mais le temps d'éxécution et beaucoup trop long : notament du fait que j'éxécute une requete dans une boucle while:
Voici comment je fais:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
//boucle pour afficher les abonné en ligne
echo"<table border=1> ";
$abonne="";
while($ligne=odbc_fetch_array($rq_cpt3))
{
if(($abonne=="") || ($abonne!=$ligne['abonne']))
{
$abonne=$ligne['abonne'];
$rq=odbc_do($conn,"SELECT DISTINCT abonne,option from osm_option where abonne='$abonne' ");
$cpt=odbc_num_rows($rq);
echo"<tr><td>" .$abonne;
for ($i=0;$i<$cpt;$i++)
{
$uneligne=odbc_fetch_array($rq);
echo "<td>"$uneligne['option'];
}
echo"</tr>";
}
$abonne=$ligne['abonne'];
}
echo" </table>"; |
Je sais ce n'est pas trés jolie
Quelqu'un saurait-il comment optimiser tout ça ?
Merci d'avance