php SERVER_COINS EMERALD TRILLIANT RADIANT CRYSTAL ONYX SAPPHIRE QUART

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
$SERVER_COINS =
[
"EMERALD" => 0,
"TRILLIANT" => 0,
"RADIANT" => 0,
"CRYSTAL" => 0,
"ONYX" => 0,
"SAPPHIRE" => 0,
"QUARTZ" => 0,
"AMBER" => 0
];
function getTableTop15()
{
global $sql;
$str = '';
$list = $sql->fetch_array('SELECT * FROM th_user WHERE id ORDER BY kg DESC LIMIT 15');
$i = 0;
foreach ($list as $key => $row)
{
$i++;
$str .= '<tr><td>' .$i .'</td><td>' .$row['nick'] .'</td><td>' .$row['kg'] .'</td><td>' .$row['server'] .'</td></tr>';
}
if ($i < 15)
{
while($i != 15)
{
$i++;
$str .= '<tr><td>' .$i .'</td><td colspan=3>Пусто</td></tr>';
}
}
return '<table><thead><tr><th>№</th><th>Ник</th><th>Кг</th><th>Сервер</th></tr></thead><tbody>' .$str .'</tbody><tfoot><tr><th colspan=4>ТОП 15</th></tr></tfoot></table>';
}
function getTableTopServers()
{
global $sql;
global $SERVER_COINS;
$str = '<table><thead><tr><th>№</th><th>Сервер</th><th>Кг</th></tr></thead><tbody>';
$list = $sql->fetch_array('SELECT * FROM th_user');
foreach ($list as $key => $row)
{
$SERVER_COINS[$row['server']] += $row['kg'];
}
$i = 0;
arsort($SERVER_COINS);
foreach ($SERVER_COINS as $key => $val)
{
$i++;
$str .= '<tr><td>' .$i .'</td><td>' .$key .'</td><td>' .$val .'</td></tr>';
}
return $str .'</tbody><tfoot><tr><th colspan=3>ТОП СЕРВЕРОВ</th></tr></tfoot></table>';
}
?>