ItsWesYo Posted November 6, 2007 Share Posted November 6, 2007 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 https://forums.phpfreaks.com/topic/76131-number_format-and-another-thing/ Share on other sites More sharing options...
pocobueno1388 Posted November 6, 2007 Share Posted November 6, 2007 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 https://forums.phpfreaks.com/topic/76131-number_format-and-another-thing/#findComment-385315 Share on other sites More sharing options...
teng84 Posted November 6, 2007 Share Posted November 6, 2007 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 https://forums.phpfreaks.com/topic/76131-number_format-and-another-thing/#findComment-385321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.