Reprise du message précédent :
baloo a écrit a écrit :
oui les utilisateurs la modifient constamment, c le but!
mais ils sont serieux...de toute façon c pour eux...et c des scientifiques!!
|
ok ça me semble qd même dangeureux pour l'intégrité de tes tables mais bon... faudra leur faire confiance !
en attendant je t'ai pondu la solution à ton pb :
<html>
<head>
<title>Test Liste champs d'une table</title>
</head>
<body>
<?php
$host = "localhost";
$user = "";
$mdp = "";
$bdd = "";
$table = "";
if(!mysql_pconnect($host, $user, $mdp)){
echo "Erreur connection a ".$host;
}
if(!mysql_select_db($bdd)){
echo "Erreur selection bdd ".$bdd;
}
$i = 0;
$Req = mysql_list_fields($bdd, $table);
$nb_champs = mysql_num_fields($Req);
echo "<table border=1>\n";
echo " <tr>\n";
for($rg = mysql_field_name($Req, $i); $i < $nb_champs; $i++) {
echo " <th>$rg</th>\n";
}
echo " </tr>\n";
$j = 0;
$Req2 = mysql_query("SELECT * FROM $table" );
while($rang = mysql_fetch_row($Req2)) {
echo " <tr>\n";
for($j = 0; $j < $nb_champs; $j++) {
echo " <td>$rang[$j]</td>\n";
}
echo " </tr>\n";
}
echo "</table>\n";
?>
</body>
<html>
normalement ça marche tout bien ! ça t'affiche le nom des champs puis ts les résultats comme ds phpMyAdmin (et j'ai même pas regardé le source pour faire ça
)