fintastik Posted July 24, 2009 Share Posted July 24, 2009 I am making a php ranking page for a game i play, I pull all the characters from the database and sort them by their level using: <table width="100%"> <tr> <th>Rank</th> <th>Name</th> <th>Character</th> <th>Level</th> </tr> <?php $data = array(); if (isset($gp_army)) { $data[] = $gp_army; } $chars = $db->query(" SELECT g.GameID, Face, Lvl FROM tblGameID1 g WHERE g.GameID NOT LIKE 'GM%' AND g.GameID NOT LIKE 'GC%' AND Permission < 65535 " . (isset($gp_type) ? ("AND Face = " . intval($gp_type)) : '' ) . " ORDER BY Lvl DESC", $data); $i = 0; while ($i < $maxdisp && $chars->fetch()) { ?> <tr> <td><-- rank cell --></td> <td ><?= htmlspecialchars($chars->GameID) ?></td> <td><?= character_type($chars->Face) ?></td> <td><?= $chars->Lvl ?></td> </tr> the problem I am having is, i want the rank cell in the table to go from 1-1000, but not sure exactly how to do it since the table is made on the fly.I messed around using a numbered list, but could only make it repeat #1 <tr> <td><ol><li></td> <td ><?= htmlspecialchars($chars->GameID) ?></td> <td><?= character_type($chars->Face) ?></td> <td><?= $chars->Lvl ?></td> </tr> any help or ideas would be appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
waynewex Posted July 24, 2009 Share Posted July 24, 2009 <tr> <td><? /*ugh short-tags*/ echo $i+1; ?></td> <td ><?= htmlspecialchars($chars->GameID) ?></td> <td><?= character_type($chars->Face) ?></td> <td><?= $chars->Lvl ?></td> </tr> Quote Link to comment Share on other sites More sharing options...
vineld Posted July 24, 2009 Share Posted July 24, 2009 That's a huge table You will not display it on a normal website I guess? Then it's no issue. If you only wish to have 1000 hits you should add LIMIT 1000 to the end of your sql command. It's unnecessary to select 50000 values if you only need 1000. You should do this to count: $counter = 0; while (blabla) { $counter++; echo $counter; } That will display the $counter value which will increase by 1 on each loop. However, you may want to correct it for equal values (there could be 10 having a score of 2538 for example). Quote Link to comment Share on other sites More sharing options...
fintastik Posted July 24, 2009 Author Share Posted July 24, 2009 thank you very much guys, your awesome Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.