afficher une liste dans un tableau en php
Posté : 07 mars 2011, 19:38
Bonjour.Je souhaite afficher une liste d'inscrits a une compétition dans un tableau a partir d'une base de donnée mais ne n'arrive qu' a afficher la partie en html .je pense que c'est au niveau de la boucle while que cela ne marche pas , je vous ai mis le code.
<?PHP
$connexion=mysql_connect("localhost","root","")OR die('Erreur de connexion');
mysql_select_db('liste des inscrits')OR die('Erreur de sélection de la base');
$requete = mysql_query('SELECT *FROM listedesinscrits') OR die('Erreur de la requête MySQL');
$liste = mysql_fetch_array($requete);
mysql_close()
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table width="100" border="0">
<tr>
<th scope="col">nom</th>
<th scope="col">prenom</th>
<th scope="col">né(e)</th>
<th scope="col">sexe</th>
<th scope="col">pays</th>
<th scope="col">dept</th>
<th scope="col">club-ville</th>
<th scope="col">payé</th>
<th scope="col">cm</th>
</tr>
</table>
<? while($liste = mysql_fetch_array($requete))
{ ?>
<tr>
<th scope="col"><? echo $liste['nom'];?></th>
<th scope="col"><? echo $liste['prenom'];?></th>
<th scope="col"><? echo $liste['né(e)'];?></th>
<th scope="col"><? echo $liste['sexe'];?></th>
<th scope="col"><? echo $liste['pays'];?></th>
<th scope="col"><? echo $liste['dept'];?></th>
<th scope="col"><? echo $liste['club-ville'];?></th>
<th scope="col"><? echo $liste['payé'];?></th>
<th scope="col"><? echo $liste['cm'];?></th>
</tr>
<? } ?>
</table>
</body>
</html>
<?PHP
$connexion=mysql_connect("localhost","root","")OR die('Erreur de connexion');
mysql_select_db('liste des inscrits')OR die('Erreur de sélection de la base');
$requete = mysql_query('SELECT *FROM listedesinscrits') OR die('Erreur de la requête MySQL');
$liste = mysql_fetch_array($requete);
mysql_close()
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table width="100" border="0">
<tr>
<th scope="col">nom</th>
<th scope="col">prenom</th>
<th scope="col">né(e)</th>
<th scope="col">sexe</th>
<th scope="col">pays</th>
<th scope="col">dept</th>
<th scope="col">club-ville</th>
<th scope="col">payé</th>
<th scope="col">cm</th>
</tr>
</table>
<? while($liste = mysql_fetch_array($requete))
{ ?>
<tr>
<th scope="col"><? echo $liste['nom'];?></th>
<th scope="col"><? echo $liste['prenom'];?></th>
<th scope="col"><? echo $liste['né(e)'];?></th>
<th scope="col"><? echo $liste['sexe'];?></th>
<th scope="col"><? echo $liste['pays'];?></th>
<th scope="col"><? echo $liste['dept'];?></th>
<th scope="col"><? echo $liste['club-ville'];?></th>
<th scope="col"><? echo $liste['payé'];?></th>
<th scope="col"><? echo $liste['cm'];?></th>
</tr>
<? } ?>
</table>
</body>
</html>