seany123 Posted September 15, 2008 Share Posted September 15, 2008 How can i get a list of 1 - 50... in my game im doing a Highscores list.. i have been able to make it so players appear where they need to etc, but i want it to display the rank also. This is the code ive made so far... i want the rank 1 - 50 underneath where it says Rank. <?php include("lib.php"); define("PAGENAME", "Bank HOF"); $player = check_user($secret_key, $db); include("templates/private_header.php"); ?><style type="text/css"> <!-- body,td,th { color: #FFFFFF; } body { background-color: #000000; } a:link { color: #FF0000; } a:visited { color: #FF0000; } a:hover { color: #666666; } a:active { color: #FF0000; } .style5 {color: #FFFFFF} --> </style> <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>Home</strong></td> </tr> </table> <table width="783" border="0"> <tr> <td><a href="levelhof.php">Level</a></td> <td><a href="moneyhof.php">Money</a></td> <td><a href="strengthhof.php">Strength</a></td> <td><a href="defencehof.php">Defence</a></td> <td><a href="speedhof.php">Speed</a></td> </tr> </table> <br> <table width="55%" border="0" align="center"> <tr> <th width="30%">Rank <th width="30%"><b>Username</b></td> <th width="30%"><b>Defense</b></td></tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `bank` from `players` order by `bank` desc limit 40"); $query = $db->execute("select `id`, `username`, `money` from `players` order by `money` desc limit 40"); while($member = $query->fetchrow()) { echo "<tr>\n"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; echo ($member['username'] == $player->username)?"<b>":""; echo $member['username']; echo ($member['username'] == $player->username)?"</b>":""; echo "</a></td>\n"; echo "<td>" . $member['money'] . "</td>\n"; echo "</tr>\n"; } ?> </table> <div align="left"> <?php include("templates/private_footer.php"); ?> </div> Link to comment https://forums.phpfreaks.com/topic/124296-need-help/ Share on other sites More sharing options...
JasonLewis Posted September 15, 2008 Share Posted September 15, 2008 Start a variable called something like $i outside the loop then in the loop increase it by 1. So at the bottom of the loop you would have: $i++; Then where rank is just echo $i. Link to comment https://forums.phpfreaks.com/topic/124296-need-help/#findComment-641855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.