<?php
require 'config.php';
$query = 'Select memb___id, ConnectTM, ConnectTm From MEMB_STAT where Connectstat=1 order by ConnectTM desc';
$result = mssql_query( $query );
echo '<center><table border="0" width="494" cellspacing="0" cellpadding="0">
<table id="rank1" class="rank1" height=30 border="1" bordercolor="333333" cellpadding="0" cellspacing="1" >
<tr>
<td align=left><font color=#666666><center>ID</center></font></td>
<td align=left><font color=#666666 ><center>Charachter</center></font></td>
<td align=left><font color=#666666><center>Class</center></font></td>
<td align=left><font color=#666666><center>Online since</center></font></td>
<td align=left><font color=#666666><center>Server</center></font></td>
<td align=left><font color=#666666><center>Level</center></font></td>
<td align=left><font color=#666666><center>Resets</center></font></td>
<td align=left><font color=#666666><center>Map</center></font></td>
</tr></center>';
$waw = mssql_query("SELECT count(*) From MEMB_STAT where Connectstat=1");
$xex = mssql_result($waw, 0, 0);
$color = 'darkblue';
for($i=0;$i < $xex;++$i)
{
$row = mssql_fetch_row($result);
$querychar = "Select GameIDC From AccountCharacter where Id='$row[0]'";
$resultchar = mssql_query( $querychar );
$accchar = mssql_fetch_row($resultchar);
$querychar = "Select Name,Class,MapNumber,clevel,resets From Character where Name='$accchar[0]'";
$resultchar = mssql_query( $querychar );
$charr = mssql_fetch_row($resultchar);
$rank = $i+1;
$get_ServerName = "Select ServerName from MEMB_STAT where memb___id='$row[0]'";
$get_ServerName_exec = $db->Execute($get_ServerName);
$get_ServerName_done = $get_ServerName_exec->fetchrow();
//Class
if ($charr['1'] == 0) { $charr[1] = "Dark Wizard"; }
if ($charr['1'] == 1) { $charr[1] = "Soul Master"; }
if ($charr['1'] == 16) { $charr[1] = "Dark Knight"; }
if ($charr['1'] == 17) { $charr[1] = "Blade Knight"; }
if ($charr['1'] == 32) { $charr[1] = "Elf"; }
if ($charr['1'] == 33) { $charr[1] = "Muse Elf"; }
if ($charr['1'] == 48) { $charr[1] = "Magic Gladiator"; }
if ($charr['1'] == 2) { $charr[1] = "Grand Master"; }
if ($charr['1'] == 18) { $charr[1] = "Blade Master"; }
if ($charr['1'] == 34) { $charr[1] = "High Elf"; }
if ($charr['1'] == 49) { $charr[1] = "Dark Master"; }
if ($charr['1'] == 65) { $charr[1] = "Lord Emperor"; }
if ($charr['1'] == 82) { $charr[1] = "Duel Master"; }
if ($charr['1'] == 64) { $charr[1] = "Dark Lord"; }
//Location
if ($charr['2'] == 0) { $charr[2] = 'Lorencia'; }
if ($charr['2'] == 1) { $charr[2] = 'Dungeon'; }
if ($charr['2'] == 2) { $charr[2] = 'Davias'; }
if ($charr['2'] == 3) { $charr[2] = 'Noria'; }
if ($charr['2'] == 4) { $charr[2] = 'Lost tower'; }
if ($charr['2'] == 5) { $charr[2] = 'Excile'; }
if ($charr['2'] == 6) { $charr[2] = 'Arena'; }
if ($charr['2'] == 7) { $charr[2] = 'Atlans'; }
if ($charr['2'] == 8) { $charr[2] = 'Tarkan'; }
if ($charr['2'] == 9) { $charr[2] = 'Devil Square'; }
if ($charr['2'] == 32) { $charr[2] = 'Devil Square'; }
if ($charr['2'] == 10) { $charr[2] = 'Icarus'; }
if ($charr['2'] == 11) { $charr[2] = 'Blood castle 1'; }
if ($charr['2'] == 12) { $charr[2] = 'Blood castle 2'; }
if ($charr['2'] == 13) { $charr[2] = 'Blood castle 3'; }
if ($charr['2'] == 14) { $charr[2] = 'Blood castle 4'; }
if ($charr['2'] == 15) { $charr[2] = 'Blood castle 5'; }
if ($charr['2'] == 16) { $charr[2] = 'Blood castle 6'; }
if ($charr['2'] == 17) { $charr[2] = 'Blood castle 7'; }
if ($charr['2'] == 18) { $charr[2] = 'CC 1'; }
if ($charr['2'] == 19) { $charr[2] = 'CC 2'; }
if ($charr['2'] == 20) { $charr[2] = 'CC 3'; }
if ($charr['2'] == 21) { $charr[2] = 'CC 4'; }
if ($charr['2'] == 22) { $charr[2] = 'CC 5'; }
if ($charr['2'] == 23) { $charr[2] = 'CC 6'; }
if ($charr['2'] == 24) { $charr[2] = 'Kalima 1'; }
if ($charr['2'] == 25) { $charr[2] = 'Kalima 2'; }
if ($charr['2'] == 26) { $charr[2] = 'Kalima 3'; }
if ($charr['2'] == 27) { $charr[2] = 'Kalima 4'; }
if ($charr['2'] == 28) { $charr[2] = 'Kalima 5'; }
if ($charr['2'] == 29) { $charr[2] = 'Kalima 6'; }
if ($charr['2'] == 30) { $charr[2] = 'Valley of Loren'; }
if ($charr['2'] == 31) { $charr[2] = 'Land Of Trials'; }
echo "<center><tr>
<td align=left><font size=1 color=#666666><b><center>$rank</center></b></font></td>
<td align=left><font size=1 color=#999999><b><center>$accchar[0]</center></b></td>
<td align=left><font size=1 color=#999999><b><center>$charr[1]</center></b></td>
<td align=left><font size=1 color=#00a650><center>$row[2]</center></td>
<td align=left><font size=1 color=yellow><center>$get_ServerName_done[0]</center></td>
<td align=left><font size=1 color=#FFFFFF><b><center>$charr[3]</center></b></td>
<td align=left><font size=1 color=#ed1c24><b><center>[$charr[4]]</center></b></td>
<td align=left><font size=1 color=#0076a3><b><center>$charr[2]</center></b></td>
</center></tr>
";
}
?>
</table>