Jump to content

number_format and another thing


ItsWesYo

Recommended Posts

1) I know how to use the number_format code, but I can't seem to get it to work for this section. $userstats3[gold] displays the amount of gold you have. It's used like this:

    print "<tr><td width='100' align='left'><b>Username</b></td><td width='100' align='left'>$player</td></tr>";
    print "<tr><td width='100' align='left'><b>User ID</b></td><td width='100' align='left'>$userstats3[iD]</td></tr>";
    print "<tr><td width='100' align='left'><b>Gold</b></td><td width='100' align='left'>$userstats3[gold]</td></tr>";

 

So, how would I do it as it seems like I can't get it to work.

 

2) I have a rankings board for the most gold and such. I'd like to have the top three people have different colored text. Gold would be 1st place, silver would be 2nd place and bronze for third. How would I got back doing this? Here's the main part:

   print "<center><table width='300' border='0'><tr><td width='100'><center><b>User ID</b></center></td><td width='100'><center><b>Username</b></center></td><td width='100'><center><b>Gold</b></center></td></tr>";
  $topplayers="SELECT * from km_users order by gold DESC Limit $start, 20";
  $topplayers2=mysql_query($topplayers) or die("Could not query players");
  while($topplayer3=mysql_fetch_array($topplayers2))
  {
    $topplayer3[playername]=strip_tags($topplayer3[playername]);
    print "<tr><td width='100'><center>$topplayer3[iD]</center></td><td width='100'><center>$topplayer3[playername]</center></td><td width='75'><center>$topplayer3[gold]</center></td></tr>";
  }
  print "</table></center>";
include 'inc/footer.php';
  }

Link to comment
Share on other sites

Here is how you would switch the colors up

 

<?php

   print "<center><table width='300' border='0'><tr><td width='100'><center><b>User ID</b></center></td><td width='100'><center><b>Username</b></center></td><td width='100'><center><b>Gold</b></center></td></tr>";
  $topplayers="SELECT * from km_users order by gold DESC Limit $start, 20";
  $topplayers2=mysql_query($topplayers) or die("Could not query players");
  
  $count = 0;
  while($topplayer3=mysql_fetch_array($topplayers2))
  {
    $topplayer3[playername]=strip_tags($topplayer3[playername]);
    
    //Put actual HEX codes for the colors
    if ($count == 1) $color = "gold";
    else if ($count == 2) $color = "silver";
    else if ($count == 3) $color = "bronze";
    else $color = "default";
    
    print "<tr><td width='100' bgcolor='$color'><center>$topplayer3[iD]</center></td><td width='100'>
    <center>$topplayer3[playername]</center></td><td width='75'><center>$topplayer3[gold]</center></td></tr>";
    
    $count++;
  }
  
  print "</table></center>";
include 'inc/footer.php';
  }
  
?>

Link to comment
Share on other sites

other approach

<style type="text/css">
<!--
.style1 {color: #FFCC33;}
.style2 {color: #FF0000;}
.style2 {color: #FF0450;}
-->
</style>
<?
while (etcccc..)
{   ++$count;
if ($count <=3){
 print "<tr><td width='100' align='left' class = 'style".$count."' ><b>Username</b></td><td width='100' align='left'>$player</td></tr>";
}
else{
print "<tr><td width='100' align='left' ><b>Username</b></td><td width='100' align='left'>$player</td></tr>";
}
}

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.