<?php
//** Connection to the database and getting the $guild_id **//
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$connection = POT::getInstance()->getDBHandle();
$CI =& get_instance();
$CI->load->helper("url");
$guild_id = $CI->uri->segment(3);
//** SQL Query **//
//** List **//
//** Functions **//
//** - Show the amount of members in guild **//
//** - Show the amount of members that are invited **//
//** - V3 Table **//
//** - Show online members in the guild **//
//** - Show the total level of members in guild **//
//** - Show the average level of members in guild **//
//** - Show the highest level in guild **//
//** - Show the lowest level in guild **//
$guildMembers = $connection->query( 'SELECT COUNT(`gr`.`id`) AS `total` FROM `players` AS `p` LEFT JOIN `guild_ranks` AS `gr` ON `gr`.`id` = `p`.`rank_id` WHERE `gr`.`guild_id` = '.$guild_id )->fetch( );
$allM = $connection->query ('SELECT COUNT(1) as `people` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') AND online = 1')->fetch();
$allM1 = $connection->query ('SELECT SUM(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch();
$allM2 = $connection->query ('SELECT AVG(`level`) as `level` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ')->fetch();
$allM3 = $connection->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` ASC LIMIT 1')->fetch();
$allM4 = $connection->query ('SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = '.$guild_id.') ORDER BY `level` DESC LIMIT 1')->fetch();
$invite = $connection->query( 'SELECT COUNT(*) FROM `guild_invites` WHERE `guild_id` = '.$guild_id.'')->fetch( );
$c1 = "#f1e0c6";
$c2 = "#d4c0a1";
$c3 = "#505050";
//** Fade Effect **/
//** You can change the speed of the fade in .fadeIn(7000) **/
//** - Start of the main content -**//
echo '
<br>
<style type="text/css">
.guildinfo {
display: table;
width:99.6%;
background-color:#eee;
border:1px solid #666666;
border-spacing:5px;
border-collapse: collaps
}
.content {
float:left;
width:50%;
background-color:#ccc;
}
.category {
display: table-row;
width:auto;
}
</style>
<div class="guildinfo">
<div class="category">
<div class="content">Number of Members in Guild</div>
<div class="content">'.$guildMembers['total'].'</div>
</div>
<div class="category">
<div class="content">Total Level in guild</div>
<div class="content">'.$allM1[0].'</div>
</div>
<div class="category">
<div class="content">Avg Level in guild</div>
<div class="content">'.round($allM2[0]).'</div>
</div>
<div class="category">
<div class="content">Lowest Level in guild</div>
<div class="content">'.$allM3[0].'</div>
</div>
<div class="category">
<div class="content">Highest Level in guild</div>
<div class="content">'.$allM4[0].'</div>
</div>
<div class="category">
<div class="content">Number of Invited Members</div>
<div class="content">'.$invite[0].'</div>
</div>
<div class="category">
<div class="content">Number of Members Online in Guild</div>
<div class="content">'.$allM[0].'</div>
</div>
</div>
';
echo "<br><br><br> ";
?>