bon jour à tous
J'aimerai savoir si le code ci-dessous (qui fonctionne) peut être considérer comme propre.
En d'autres termes, est-ce ainsi que l'on alimente un tableau html pour afficher des données issues de mysql:
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 <?php // suite.... $query = "SELECT * FROM ".DB_TBL ; $resultat = mysql_query($query, $connection) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); $nb_enregis = mysql_num_rows($resultat); ?> <body> <p> </p> <table width="800" border="1"> <tr> <th width="30" scope="col">id</th> <th width="200" scope="col">pseudo</th> <th width="250" scope="col">mail</th> <th width="127" scope="col">mdp</th> <th width="105" scope="col">date</th> <th width="25" scope="col">Activé</th> </tr> <?php while ( $nb_enregis = mysql_fetch_row( $resultat ) ){ echo "<tr> <td>$nb_enregis[0]</td> <td>$nb_enregis[1]</td> <td>$nb_enregis[2]</td> <td>$nb_enregis[3]</td> <td>$nb_enregis[4]</td> <td>$nb_enregis[5]</td> </tr>"; } ?> </table> <p> </p> </body>
Partager