<style>
table {font-size:11px;font-family:tahoma, arial, sans-serif;width:40%;}
td{border:1px solid #000;padding: 4px 3px;height: 25px;}
</style>
<?require('../config.php');
require_once("setup_status.php");
for($i=1;$i<=6;$i++){?>
      <p><table align="center">
      <tr style="background: #C5E6FC;">
      <td colspan="3" align="center"><b>TOP20 <?=$st_users[$i]["name"]?></b></td>
      </tr><tr style="background: #99FBA0;">
      <td align="center" style="width:30px;"><b>№</b></td>
      <td align="center"><b>Логин</b></td>
      <td align="center"><b>Баллов</b></td>
      </tr>
<?$res = mysql_query("SELECT `username`,`ball` FROM `tb_users` WHERE `ball_status` = '$i' ORDER BY `ball` DESC LIMIT 20");
if(mysql_num_rows($res) > 0){
$b = 1;
while ($row = mysql_fetch_assoc($res))
{?>
      <tr>
      <td align="center"><b><?=$b++;?></b></td>
      <td align="center"><?=$row["username"]?></td>
      <td align="center"><?=$row["ball"]?></td>
      </tr>
<?}
}else{?>
<tr>
<td colspan="3" align="center"><b style="color:red;">Нет пользователей с данным статусом</b></td>
</tr>
<?}?>
</table></p>
<?}?>