query("
SELECT
hlstats_Servers.name AS server,
SUM(hlstats_Events_Frags.killerId = $player) AS kills,
SUM(hlstats_Events_Frags.victimId = $player) AS deaths,
SUM(hlstats_Events_Frags.killerId = $player) / IF(SUM(hlstats_Events_Frags.victimId = $player) = 0, 1, SUM(hlstats_Events_Frags.victimId = $player)) AS kpd,
ROUND(SUM(hlstats_Events_Frags.killerId = $player) / $realkills * 100, 2) AS kpercent,
ROUND(SUM(hlstats_Events_Frags.victimId = $player) / $realdeaths * 100, 2) AS dpercent,
SUM(hlstats_Events_Frags.killerId = $player AND hlstats_Events_Frags.headshot = 1) AS headshots,
IFNULL(SUM(hlstats_Events_Frags.killerId = $player AND hlstats_Events_Frags.headshot = 1) / SUM(hlstats_Events_Frags.killerId = $player), '-') AS hpk,
ROUND(SUM(hlstats_Events_Frags.killerId = $player AND hlstats_Events_Frags.headshot = 1) / $realheadshots * 100, 2) AS hpercent
FROM
hlstats_Events_Frags
LEFT JOIN
hlstats_Servers
ON
hlstats_Servers.serverId = hlstats_Events_Frags.serverId
WHERE
hlstats_Servers.game = '$game'
AND hlstats_Events_Frags.killerId = '$player'
OR hlstats_Events_Frags.victimId = '$player'
GROUP BY
hlstats_Servers.name
ORDER BY
$tblServers->sort $tblServers->sortorder,
$tblServers->sort2 $tblServers->sortorder
");
$numitems = $db->num_rows($result);
if ($numitems > 0)
{
printSectionTitle('Server Activity *');
$tblServers->draw($result, $numitems, 95);
?>