<?php
function con_error($msg)
{
echo $msg;
@mysql_close();
die();
}
$host = "localhost";
$usr = "";
$pwd = "";
if ($db==1) $db = "l2_low_new";
if ($db==2) $db = "l2_high_new";
$mysql_con = mysql_connect($host,$usr,$pwd);
if (!$mysql_con) {
con_error("Database server is down at the moment. Please try again later!");
}
$db_con = mysql_select_db($db);
if (!$db_con) {
con_error("An error has occured. Please inform the admin! Error: Database not found!");
}
$res_clans = mysql_query("
SELECT
`cd`.`clan_name`,
`cd`.`clanid`,
(COUNT(*) - 1) AS `member_count`,
`c`.`char_name` AS `leader_name`
FROM `clan_data` AS `cd`
LEFT JOIN `characters` USING (`clanid`)
LEFT JOIN `characters` AS `c` ON (`c`.`obj_id` = `cd`.`leader_id`)
GROUP BY `cd`.`clanid`
ORDER BY `member_count` DESC");
if (!$res_clans) {
con_error("<br><br>There are no clans on this server");
}
$clans_count = @mysql_num_rows($res_clans);
echo "<center><h5>".$clans_count." clan(s) registered</h5>";
echo "<table border='1'><tr><th><center>Ranking</center></th><th><center>Clans</center></th><th><center>Members</center></th><th><center>Leader</center></th></tr>";
$ranking = 1;
while($row_clan = @mysql_fetch_array($res_clans)) {
echo "<tr><td><center>".$ranking."</center></td><td><center>".$row_clan['clan_name']."</center></td><td><center>".$row_clan['member_count']." Member(s)</center></td><td><center>".$row_clan['leader_name']."</center></td></tr>";
$ranking++;
if ($ranking > 100) break;
}
echo "</table></center>";
mysql_close();
die();
?>