Jump to content

[SOLVED] For + While Problems


marcus

Recommended Posts

I'm trying to create a high score list while show the correct placement of the user, 1-10.

 

Code:

<?php
$global_check=3;
include('../global.php');
$sql = "SELECT * FROM `characters` ORDER BY `royal` DESC LIMIT 10";
$res = mysql_query($sql) or die(mysql_error());
echo "<center>\n";
echo "<table border=0 cellspacing=3 cellpadding=3 width=400>\n";
echo "<tr><td colspan=3 align=center class=bar><font class=barfont>test</font></td></tr>\n";
echo "<tr><td align=center>#</td><td align=center>Username</td><td align=center>Points</td></tr>\n";
for($i=1;$i<11;$i++){
while($row = mysql_fetch_assoc($res)){
echo "<tr><td align=center>$i</td><td align=center>$row[username]</td><td align=center>$row[royal]</td></tr>\n";
}
}
echo "</table></center>\n";
?>

 

Result:

 

test

# Username Points

1 marcus 175

1 neoisboring 149

1 hxcChaos 74

1 Jen 71

1 Sparts 49

1 SpiritWarrior 23

1 Damon 23

1 Sarah 21

1 Rachykins 17

1 kellykoo 16

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.