Rang classement PHP

Fermé
Ulrich7 - Modifié par Ulrich7 le 26/03/2011 à 18:19
CubeRCL Messages postés 9 Date d'inscription samedi 8 septembre 2007 Statut Membre Dernière intervention 28 mars 2011 - 28 mars 2011 à 11:26
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.



A voir également:

5 réponses

CubeRCL Messages postés 9 Date d'inscription samedi 8 septembre 2007 Statut Membre Dernière intervention 28 mars 2011 2
28 mars 2011 à 11:26
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
1
michel_m Messages postés 16603 Date d'inscription lundi 12 septembre 2005 Statut Contributeur Dernière intervention 16 décembre 2023 3 303
26 mars 2011 à 18:14
Bonjour,

Quel logiciel et/ou langage ?
0
Oups, c'est du PHP :)
0
CubeRCL Messages postés 9 Date d'inscription samedi 8 septembre 2007 Statut Membre Dernière intervention 28 mars 2011 2
26 mars 2011 à 18:35
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
0

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>
0