Rang classement PHP
Ulrich7
-
CubeRCL Messages postés 9 Statut Membre -
CubeRCL Messages postés 9 Statut Membre -
Bonjour, Voici mon problème :
J'ai un tableau :
____________________
| Rang | Pseudo | Points |
----------------------------
| | Marc | 58 |
----------------------------
| | Michel | 23 |
----------------------------
| | Max | 7 |
----------------------------
Et je souhaiterais que dans ma colonne "Rang", à chaque ligne apparaisse un nombre, première ligne : 1, deuxième : 2 troisième : 3 etc...
C'est à dire ça :
____________________
| Rang | Pseudo | Points |
----------------------------
| 1 | Marc | 58 |
----------------------------
| 2 | Michel | 23 |
----------------------------
| 3 | Max | 7 |
----------------------------
Merci d'avance pour votre aide.
J'ai un tableau :
____________________
| Rang | Pseudo | Points |
----------------------------
| | Marc | 58 |
----------------------------
| | Michel | 23 |
----------------------------
| | Max | 7 |
----------------------------
Et je souhaiterais que dans ma colonne "Rang", à chaque ligne apparaisse un nombre, première ligne : 1, deuxième : 2 troisième : 3 etc...
C'est à dire ça :
____________________
| Rang | Pseudo | Points |
----------------------------
| 1 | Marc | 58 |
----------------------------
| 2 | Michel | 23 |
----------------------------
| 3 | Max | 7 |
----------------------------
Merci d'avance pour votre aide.
A voir également:
- Rang classement PHP
- Easy php - Télécharger - Divers Web & Internet
- Logiciel classement photo gratuit - Guide
- Logiciel de classement de documents gratuit - Télécharger - Bureautique
- Expert php pinterest - Télécharger - Langages
- Classement meilleur ami snap - Forum Snapchat
5 réponses
Il te suffit de gerer un petit compteur ...
//Init
$compteur=0;
while($dnn = mysql_fetch_array($req))
{
$compteur++;
?>
<tr>
<td><?php echo $compteur; ?></td>
<td><a href="profilparc.php?id=<?php echo $dnn['userid']; ?>"><?php echo htmlentities($dnn['username']); ?></td>
<td><?php echo htmlentities($dnn['level']); ?></a></td>
<td><?php echo htmlentities($dnn['argent']); ?></td>
<td><?php echo htmlentities($dnn['points']); ?></td>
<td><?php echo htmlentities($dnn['nbescargot']); ?></td>
</tr>
<?php
}
/* Reinitialisation du compteur pour etre utiliser dans un autre tableau */
$compteur=0;
Hope it helps
Cube
//Init
$compteur=0;
while($dnn = mysql_fetch_array($req))
{
$compteur++;
?>
<tr>
<td><?php echo $compteur; ?></td>
<td><a href="profilparc.php?id=<?php echo $dnn['userid']; ?>"><?php echo htmlentities($dnn['username']); ?></td>
<td><?php echo htmlentities($dnn['level']); ?></a></td>
<td><?php echo htmlentities($dnn['argent']); ?></td>
<td><?php echo htmlentities($dnn['points']); ?></td>
<td><?php echo htmlentities($dnn['nbescargot']); ?></td>
</tr>
<?php
}
/* Reinitialisation du compteur pour etre utiliser dans un autre tableau */
$compteur=0;
Hope it helps
Cube
Bonjour
Oui, mais la question est comment tu as les données ?
Affiche tu un tableau php ? Si oui, donne ton code, il faut juste un sort a mon avis ...
Recupere tu des donnees SQL ? De meme donne le code, dans la command SQL, tu peux ordonner tes donnees.
Cube
Oui, mais la question est comment tu as les données ?
Affiche tu un tableau php ? Si oui, donne ton code, il faut juste un sort a mon avis ...
Recupere tu des donnees SQL ? De meme donne le code, dans la command SQL, tu peux ordonner tes donnees.
Cube
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<table class="profil">
<tr>
<td>Rang</td>
<td>Pseudo</td>
<td>Niveau</td>
<td>Argent</td>
<td>Points</td>
<td>Nombre d'escargot</td>
</tr>
<?php
$req = mysql_query('select username, userid, level, nbescargot, argent, points from escargot ORDER BY level DESC');
while($dnn = mysql_fetch_array($req))
{
?>
<tr>
<td>ICI LE RANG</td>
<td><a href="profilparc.php?id=<?php echo $dnn['userid']; ?>"><?php echo htmlentities($dnn['username']); ?></td>
<td><?php echo htmlentities($dnn['level']); ?></a></td>
<td><?php echo htmlentities($dnn['argent']); ?></td>
<td><?php echo htmlentities($dnn['points']); ?></td>
<td><?php echo htmlentities($dnn['nbescargot']); ?></td>
</tr>
<?php
}
?>
</table>