|
oim 1453
| Posté : 08-03-2007 18:52
Slt, comment on fait pour afficher dans un fichier php le contenu d'une table sans connaitre les champs ? |  Profil www
|
|
Tito 7758
| Posté : 08-03-2007 19:19
Allé, je t'écris vite un petit code :
<?php
$query = mysql_query("SELECT * FROM table");
$row = mysql_fetch_assoc($query));
echo '<table><tr>';
foreach($row as $nom=>$col) echo '<th>'.$nom.'&l t;/th>';
echo '</tr><tr>';
foreach($row as $col) echo '<td>'.$nom.'</td> ';
echo '</tr>';
while($row = mysql_fetch_assoc($query)) {
echo '<tr>';
foreach($row as $col) echo '<t d>'.$col.'</td>';
echo '</tr>';
}
echo '</table>';
?>
Non testé mais ça me semble pas mal |  Profil E-mail www
|
|
Tito 7758
| Posté : 08-03-2007 19:38
Versi corrigée :
<?php
$query = mysql_query("SELECT * FROM table");
$row = mysql_fetch_assoc($query));
echo '<table><tr>';
foreach($row as $nom=>$col) echo '<th>'.$nom.'&a mp;l t;/th>';
echo '</tr><tr>';
foreach($row as $col) echo '<td>'.$nom.'</td> ';
echo '</tr>';
while($row = mysql_fetch_assoc($query)) {
echo '<tr>';
foreach($row as $col) echo '<t d>'.$col.'</td>';
echo '</tr>';
}
echo '</table>';
?>
|  Profil E-mail www
|
|
oim 1453
| |