ColinMaudry Posted June 28, 2008 Share Posted June 28, 2008 Bonjour, Je développe un glossaire mulilingue en ligne, et j'aimerais afficher le contenu de ma table "glossaire". Structure : id | texte source| note| statut | langue 1| langue 2| etc...| La subtilité, c'est que j'aimerais que le script n'ait pas à être modifié si on ajoute ou supprime des langues. Pour l'affichage des en-têtes de colonnes, j'ai réussi, mais je bloque sur l'affichage des lignes. Je pensais vraiment pas bloquer là-dessus . Trêve de palabres, voici le code : <?php include 'includes/db_login.php'; //We fetch the glossary data on the DB $query2 = mysql_query('SELECT * FROM glossary ORDER BY id DESC'); $nb_rows = mysql_num_rows($query2); $nb_fields = mysql_num_fields($query2); //We set the width of the div and the table, proportional //with the number of fields $table_width=(510+($nb_fields - 4)*183) ; $div_width=($table_width + 20) ; echo ' <div id="mainbody" style="width:'.$table_width.'px;"> <table style="width:'.$table_width.'px;"> '; //We display the column headers echo ' <tr> <th class="id">id</th> <th class="source">Source</th> <th class="note">Client note</th> <th class="status">Status</th>'; for($i=4;$i<=($nb_fields-1);$i++){ echo '<th class="trans">'.mysql_field_name($query2, $i) .'</th>'; } echo '</tr>'; //We display the rows while ($data = mysql_fetch_array($query2) ) { echo ' <tr> <td class="id">'.$data['id'].'</td> <td class="source">'.$data['source'].'</td> <td class="note">'.$data['note'].'</td> <td class="status">'.$data['status'].'</td> '; //L'oubli est réparé, merci Mephisto!! for($i=4;$i<=($nb_fields-1);$i++){ echo '<td class="trans">'.$data[$i] .'</td>'; } ' </tr> '; } ?> </table> </div> Résultat : - j'ai le bon nombre de colonnes, les en-têtes s'affichent correctement - j'ai le bon nombre de lignes - le contenu des colonnes "fixes" (id, source, note et status) s'affiche nickel - MAIS pas le contenu des colonnes langue1, langue2, etc (j'en ai 19 pour l'instant ) Comment faire ? Link to comment Share on other sites More sharing options...
Mephisto Posted June 28, 2008 Share Posted June 28, 2008 ben, t'echo $data, c'est choquant essaye avec $i Link to comment Share on other sites More sharing options...
ColinMaudry Posted June 28, 2008 Author Share Posted June 28, 2008 Grrrr merci beaucoup, faut vraiment que j'aille me coucher Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.