Problème mysql_fetch_array
Résolu
Imer
-
maily Messages postés 7556 Date d'inscription Statut Contributeur Dernière intervention -
maily Messages postés 7556 Date d'inscription Statut Contributeur Dernière intervention -
Salut à tous,
j'ai fais une requête et je veux afficher les résultats dans différentes colonnes d'un tableau...
Voila ma requête :
Ensuite pour l'affichage je fais un fetch array... Mais le problème c'est que je le fais dans chaque colonne ce qui n'a pas l'air de lui plaire puiqu'il n'y a que le premier fetch_array qui affiche quelquechose...
Voila mon code ca vous permettra surement de mieu comprendre :
PHP Code
En fait PHP ne m'affiche que le premier fetch_array, donc il faudrais que je regroupe tout dans un seul mais ensuite comment intéger mon tableau dedans?
Voila si quelqu'un a un petit tuyau...
Merci d'avance...
j'ai fais une requête et je veux afficher les résultats dans différentes colonnes d'un tableau...
Voila ma requête :
$carac = mssql_query("SELECT nml_variable, unite, iso, afnor, nolcl*lcl AS Lcl, noaim*aim AS Aim, noucl*ucl AS Ucl FROM variable_affiche AS C1, variable_bis AS C2, specdata AS C3 WHERE C3.idsubdoc = '$subdoc' AND C3.idparameter = C2.idvariable AND C2.nml = C1.nml_variable AND C1.product_param2 = '$su' ORDER BY C1.sequence");
Ensuite pour l'affichage je fais un fetch array... Mais le problème c'est que je le fais dans chaque colonne ce qui n'a pas l'air de lui plaire puiqu'il n'y a que le premier fetch_array qui affiche quelquechose...
Voila mon code ca vous permettra surement de mieu comprendre :
PHP Code
... $carac = mssql_query("SELECT nml_variable, unite, iso, afnor, nolcl*lcl AS Lcl, noaim*aim AS Aim, noucl*ucl AS Ucl FROM variable_affiche AS C1, variable_bis AS C2, specdata AS C3 WHERE C3.idsubdoc = '$subdoc' AND C3.idparameter = C2.idvariable AND C2.nml = C1.nml_variable AND C1.product_param2 = '$su' ORDER BY C1.sequence"); ?> <script type="text/javascript"> window.print() ; </script> <table width="593" border="0" align="center" cellspacing="0"> <tr> <th width="113" height="77" scope="row"><img src="../Logoarjowiggins.JPG" width="106" height="75"></th> <td width="260"> </td> <td width="214" class="contenu2"><? echo"DATE D'EDITION : ".date('d/m/Y'); ?></td> </tr> </table> <table width="200" border="0" align="center" cellspacing="0"> <tr> <th width="664" scope="row"><table width="200" border="2" align="center" cellspacing="1" bordercolor="#000033"> <tr> <th align="center" valign="bottom" bordercolor="#000033" class="contenu3" scope="row">FICHE TECHNIQUE </th> </tr> </table></th> </tr> <tr> <td height="30" scope="row"></td> </tr> <tr> <th scope="row"><table width="603" border="2" align="center" cellpadding="1" cellspacing="0" bordercolor="#000033"> <tr bordercolor="#CCCCCC" class="contenu"> <th bordercolor="#000033" scope="row"><div align="right">QUALITE PAPIER :</div></th> <td bordercolor="#000033"><? echo $papier; ?></td> </tr> <tr bordercolor="#CCCCCC" class="contenu"> <th width="125" bordercolor="#000033" scope="row"><div align="right">CODE PAPIER :</div></th> <td width="466" bordercolor="#000033"><? echo $codepapier; ?></td> </tr> </table></th> </tr> <tr> <th height="10" scope="row"> </th> </tr> <tr> <th height="50" scope="row"><table width="672" border="1" cellpadding="1" cellspacing="0" bordercolor="#000000"> <tr> <th width="184" rowspan="2" scope="row">CARACTERISTIQUES</th> <th width="70" rowspan="2">UNITE</th> <th colspan="2">REFERENCE NORME</th> <th colspan="3">SPECIFICATION</th> </tr> <tr> <th width="96">Afnor</th> <th width="85">Iso</th> <th width="69">Ctrl. bas</th> <th width="70">Objectif</th> <th width="68">Ctrl. haut</th> </tr> <tr> <td scope="row"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['nml_variable']."</br>"; } ?></td> <td valign="top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['unite']."</br>"; } ?></td> <td valign="top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['iso']."</br>"; } ?></td> <td valign="top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['afnor']."</br>"; } ?></td> <td valign="top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['Lcl']."</br>"; } ?></td> <td valign="top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['Aim']."</br>"; } ?></td> <td valign"top" align="center"><? while ($sortie = mssql_fetch_array($carac)) { echo $sortie['Ucl']."</br>"; } ?></td> </tr> ....
En fait PHP ne m'affiche que le premier fetch_array, donc il faudrais que je regroupe tout dans un seul mais ensuite comment intéger mon tableau dedans?
Voila si quelqu'un a un petit tuyau...
Merci d'avance...
1 réponse
mysql_fetch_array($result, MYSQL_ASSOC)
Bonjour,
Tu as plusieurs problème!
Quand tu fais un mysql_fetch_array, ça te renvoie l'enregistrement entier, c'est à dire, toute les colonne pour un seul enregistrement, et puis, il faut que tu précise que tu vas utiliser le nom des colonnes pour l'accès dans le tableau avec MYSQL_ASSOC, donc:
Bonjour,
Tu as plusieurs problème!
Quand tu fais un mysql_fetch_array, ça te renvoie l'enregistrement entier, c'est à dire, toute les colonne pour un seul enregistrement, et puis, il faut que tu précise que tu vas utiliser le nom des colonnes pour l'accès dans le tableau avec MYSQL_ASSOC, donc:
<? while ($sortie = mssql_fetch_array($carac, MYSQL_ASSOC)) { <tr> <td scope="row"> echo $sortie['nml_variable']."</br>"; ?></td> <td valign="top" align="center"><? echo $sortie['unite']."</br>"; ?></td> <td valign="top" align="center"><? { echo $sortie['iso']."</br>"; ?></td> <td valign="top" align="center"><? echo $sortie['afnor']."</br>"; ?></td> <td valign="top" align="center"><? echo $sortie['Lcl']."</br>"; ?></td> <td valign="top" align="center"><? echo $sortie['Aim']."</br>"; ?></td> <td valign"top" align="center"><? echo $sortie['Ucl']."</br>"; ?></td> </tr> <? } ?>