Récuperation des données d'une table
Bonjour,
Voila, j'ai une table "cnrs" qui comprend 4 attributs: num, nom, prénom et âge. J'ai voulu récupérer toutes ces données dans un tableau mais lors de l'exécution, seules les valeurs de la colonne "num" apparaissent.
Voici la capture d'écran du résultat :
http://img713.imageshack.us/img713/688/php.jpg
et le code :
Code:
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 36
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$idcom=mysql_connect("localhost","root");
if(!$idcom){echo "non";}else {echo "oui";}
echo $idcom."</br>";
$idbase = mysql_select_db("personnelle",$idcom);
$requete="SELECT * FROM cnrs ORDER BY nom";
$result=mysql_query($requete,$idcom);
echo $result;
if(!$result){
echo "Lecture impossible";
}else{
$nbcol=mysql_num_fields($result);
$nbpersonne=mysql_num_rows($result);
echo "<h3> LE PERSONNEL DU CNRS</h3>";
echo "<h4> Il y a $nbpersonne personnes au CNRS </h4>";
echo "<table border=\"1\"><tbody>";
echo "<tr><th>num</th> <th>nom</th> <th>prenom</th><th>age</th></tr>";
while($ligne=mysql_fetch_array($result,MYSQL_NUM)){
echo "<tr>";
foreach($ligne as $valeur);{
echo "<td> $valeur </td>";
}
echo "</tr>";
}
echo "</tbody></table>";
}
?>
</body>
</html> |