Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Résolu] [php] Afficher les lignes d'une table

Featured Replies

Posté(e)

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 :zarb: . 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 :francais: )

Comment faire ?

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.