PHP afficher un tableau par ordre

Fermé
tinabriga - 13 oct. 2008 à 16:41
plubarj Messages postés 101 Date d'inscription jeudi 17 avril 2008 Statut Contributeur Dernière intervention 13 octobre 2008 - 13 oct. 2008 à 16:45
Bonjour,

J'ai créer un tableau mais j'aimerais que mes résultats s'affichent par le nom de la poule (poule A, poule B,...)

Mon tableau n'affiche que le résultat de la dernière poule, je pense que je dois utiliser le foreach mais je n'y suis pas arriver.

Voilà mon code :

echo '<table width="650" border="5" align="center">';
echo "<h2>Poule ".$poule."</h2>";
echo '<tr><th>Position</th><th>Nom</th><th>Prénom</th><th>Score</th><th>Pays</th></tr>';
$sql3="SELECT * FROM joueurs, tour_participant WHERE joueurs.Id_joueur=tour_participant.id_participant AND tour_participant.tournoi = '$tournoi' AND tour_participant.poule='$poule' AND tour_participant.tour=4 order by tour_participant.score DESC ";
$result=mysql_query($sql3) or die("not ok");
$i=0;

while ($row = mysql_fetch_array($result))
{
$i++;
echo '<tr>';
echo "<td>$i</td>";
echo "<td>".$row["Nom"]."</td>";
echo "<td>".$row["Prenom"]."</td>";
echo "<td>".$row["score"]."</td>";
echo "<td>".$row["Pays"]."</td>";
echo '</tr>';
}

echo '</table>';
?>

$poule représente la valeur de poule récupérer via :
while ($data = mysql_fetch_array($result1)){
echo "<input type=\"hidden\" name=\"poule\" value =\"".$data['poule']."\">";
//echo "<value=\"".$data['poule'];
}
Merci d'avance pour toute aide.
A voir également:

1 réponse

plubarj Messages postés 101 Date d'inscription jeudi 17 avril 2008 Statut Contributeur Dernière intervention 13 octobre 2008 6
13 oct. 2008 à 16:45
Hello
Pour l'instant tu récupères tes données par ordre décroissant du score:
"... order by tour_participant.score DESC"
modifie ta requête SQL comme ça
"... order by tour_participant.poule"
Ca devrait le faire...
Cheers
-1