Afficher données SQL dans tableau

Résolu/Fermé
labourette Messages postés 657 Date d'inscription dimanche 24 août 2008 Statut Membre Dernière intervention 24 juillet 2016 - 21 sept. 2010 à 08:12
labourette Messages postés 657 Date d'inscription dimanche 24 août 2008 Statut Membre Dernière intervention 24 juillet 2016 - 21 sept. 2010 à 10:09
Bonjour,

Quelques petites explications s'il vous plait je ne comprend pas bien, c'est vraiment bizarre.
J'ai fait 6 tableau sur ma page pour récupérer des données provenant de ma BDD.

En fait ça ne fonctionne pas comme je le voudrais non pas pour récupérer les données mais pour les afficher correctement.
Chaque fois que je rajoute une données via mon formulaire ça me rajoute un tableau en fait ça m'affiche 1 données par tableau.
Par exemple tous les utilisateurs qui ont 1 clairon s'affiche dans la table "clairon"
Cela est fait pour la gestion d'instruments de musique
Je vous donne mon code il est long mais c'est juste mes 6 tableaux HTML
Merci vraiment pour votre aide.

<?php
$resultats = $bdd->query("SELECT *
FROM utilisateur
WHERE 'utilisateur'.'clairon_numero' <> ''
OR 'utilisateur'.'cor_numero' <> ''
OR 'utilisateur'.'tptecaval_numero' <> '' 
OR 'utilisateur'.'tambour_numero' <> ''
OR 'utilisateur'.'cymbale_numero' <> ''
OR 'utilisateur'.'grosse_caisse_numero' <> ''
AND 'utilisateur'.'membre' <> 'sortant'
AND 'utilisateur'.'nom' <> 'ADMINISTRATEUR'
AND 'utilisateur'.'membre' <> 'non_musicien'
ORDER BY clairon_numero, cor_numero ASC");
$donnees = $resultats->setFetchMode(PDO::FETCH_OBJ);

while ($donnees = $resultats->fetch())
{
?>

<!-- TABLEAU CLAIRON -->
<table style="width: 500; float: left"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="5">CLAIRON</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th>
		<th width="100" class="table-entete">Embouchure</th>
		<th width="100" class="table-entete">Poignée</th>
		<th width="100" class="table-entete">Cordon</th>  
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->clairon_numero;?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->embouchure_cl==1){ echo $donnees->embouchure_cl;}?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->poignee_cl==1){ echo $donnees->poignee_cl;}?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->cordon_cl==1){ echo $donnees->cordon_cl;}?></td>		
	</tr>
</table>
		</td>
	</tr>
</table>
<!-- TABLEAU COR -->
<table width="300"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="3">COR</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th>
		<th width="100" class="table-entete">Embouchure</th>
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->cor_numero;?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->embouchure_cor==1){ echo $donnees->embouchure_cor;}?></td>		
	</tr>
</table>
		</td>
	</tr>
</table>

<!-- TABLEAU TROMPETTE DE CAVALERIE -->
<table style="width: 500; float: left"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="5">TROMPETTE DE CAVALERIE</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th>
		<th width="100" class="table-entete">Embouchure</th>
		<th width="100" class="table-entete">Poignée</th>
		<th width="100" class="table-entete">Cordon</th>  
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->tptecaval_numero;?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->embouchure_tptecav==1){ echo $donnees->embouchure_tptecav;}?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->poignee_tptecav==1){ echo $donnees->poignee_tptecav;}?></td>
		<td width="100" class="table-ligne1"><?php if($donnees->cordon_tptecav==1){ echo $donnees->cordon_tptecav;}?></td>		
	</tr>
</table>
		</td>
	</tr>
</table>
<!-- TABLEAU CYMBALES -->
<table width="200"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="2">CYMBALES</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th> 
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->cymbale_numero;?></td>	
	</tr>
</table>
		</td>
	</tr>
</table>
<!-- TABLEAU TAMBOUR -->
<table style="width: 400; float: left"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="4">TAMBOUR</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th>
		<th width="100" class="table-entete">Baudrier</th>
		<th width="100" class="table-entete">Baguettes</th> 
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->tambour_numero;?></td>
		<td width="100" class="table-ligne1"><?php echo $donnees->baudrier_numero;?></td>
		<td width="100" class="table-ligne1"><?php echo $donnees->baguette_numero;?></td>	
	</tr>
</table>
		</td>
	</tr>
</table>
<!-- TABLEAU GROSSE CAISSE -->
<table width="200"> 
	<tr>
		<td class="table-separateur">
<table width="100%" border="2" cellspacing="1" cellpadding="5">
	<tr><td class="table-titre" colspan="2">GROSSE CAISSE</td></tr>
	<tr>
		<th width="100" class="table-entete">Nom / Prénom</th>
		<th width="100" class="table-entete-centre">Numéro</th> 
	</tr>
	<tr>
		<td width="100" class="table-ligne1"><?php echo $donnees->nom.'&nbsp;</b>'.$donnees->prenom; ?></td>
		<td width="100" class="table-ligne1-centre"><?php echo $donnees->grosse_caisse_numero;?></td>	
	</tr>
</table>
		</td>
	</tr>
</table>
<?php
}
?>


2 réponses

Neliel Messages postés 6146 Date d'inscription jeudi 9 juillet 2009 Statut Contributeur Dernière intervention 20 mars 2017 1 688
21 sept. 2010 à 08:19
Bonjour,

Normal, tu as mis les balises d'ouverture et de fermeture de tableau dans ta boucle while. C'est à dire qu'à chaque fois qu'il trouve des données, il ouvre et ferme un tableau.
Place tes <table> et </table> en dehors de la boucle while comme ceci:


...
<table>
<?php
while($donnees = $resultats->fetch())
{
...
}
?>
</table>
...
0
labourette Messages postés 657 Date d'inscription dimanche 24 août 2008 Statut Membre Dernière intervention 24 juillet 2016 6
21 sept. 2010 à 10:09
Bonjour

Super génial ça marche nickel j'apprends petit à petit le php.

Merci beaucoup
0