PHP Code:
<?php
$SERVER="";
$USER="";
$PASS="";
$DB_NAME="ASD";
$LINK=mssql_connect($SERVER,$USER,$PASS);
$DB=mssql_select_db($DB_NAME,$LINK);
//$lines="100 PERCENT";
$lines="100";
if (!isset($_GET['t']))
{
$t = 0;
}
else
{
$t = floor($_GET['t']);
}
$aClass = array(
0 => 'Warrior',
1 => 'Knight',
2 => 'Mage',
3 => 'Archer');
$strSQL = "SELECT TOP {$lines} ";
$strSQL .= "c_id as char, ";
$strSQL .= "c_sheaderb as class, ";
$strSQL .= "c_sheaderc as level, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 1) AS int) as str, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 2) AS int) as int, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 3) AS int) as dex, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 4) AS int) as vit, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 5) AS int) as mana, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 7) AS int) as HP, ";
$strSQL .= "CAST(dbo.fnSplit(c_headera, ';', 8) AS int) as MP, ";
$strSQL .= "c_headerc as gold, ";
$strSQL .= "CONVERT(VARCHAR, d_udate, 105) + ' ' + CONVERT(VARCHAR, d_udate, 108) as laston ";
$strSQL .= "from charac0 (nolock) ";
$strSQL .= "where (not d_udate IS NULL) ";
switch ($t)
{
case 1: // str
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 1) AS int) DESC ";
break;
case 2: // int
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 2) AS int) DESC ";
break;
case 3: // dex
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 3) AS int) DESC ";
break;
case 4: // vit
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 4) AS int) DESC ";
break;
case 5: // mana
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 5) AS int) DESC ";
break;
case 7: // HP
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 7) AS int) DESC ";
break;
case 8: // MP
$strSQL .= "ORDER BY CAST(dbo.fnSplit(c_headera, ';', 8) AS int) DESC ";
break;
case 10: // gold
$strSQL .= "ORDER BY CAST(c_headerc as int) DESC ";
break;
case 11: // date
$strSQL .= "ORDER BY d_udate DESC ";
break;
default: // level (t=0)
$strSQL .= "ORDER BY CAST(c_sheaderc as int) DESC ";
}
$res=mssql_query($strSQL, $LINK);
?>
<html>
<head>
<title>TOPs :: Project A3</title>
<STYLE>
body {font-family: Verdana; font-size: 12px; BACKGROUND: #94B6C6; color: black}
td {font-family: Verdana; font-size: 11px; color: black;}
td.h {font-family: Verdana; font-size: 12px; color: black; background-color: #A6B6C6;}
</STYLE>
</head>
<body TOPMARGIN="5">
<table align=center border=1 cellpadding=1 cellspacing=1>
<tr align=center height=25>
<td width= 30 class=h>№</td>
<td width=150 class=h>Name</td>
<td width= 50 class=h>Class</td>
<td width= 50 class=h><a href="a3tops.php?t=0"><?php if ($t==0) echo "<b><font color=red>";?>Level<?php if ($t==0) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=1"><?php if ($t==1) echo "<b><font color=red>";?>STR <?php if ($t==1) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=2"><?php if ($t==2) echo "<b><font color=red>";?>INT <?php if ($t==2) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=3"><?php if ($t==3) echo "<b><font color=red>";?>DEX <?php if ($t==3) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=4"><?php if ($t==4) echo "<b><font color=red>";?>VIT <?php if ($t==4) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=5"><?php if ($t==5) echo "<b><font color=red>";?>Mana <?php if ($t==5) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=7"><?php if ($t==7) echo "<b><font color=red>";?>HP <?php if ($t==7) echo "</font></b>";?></a></td>
<td width= 50 class=h><a href="a3tops.php?t=8"><?php if ($t==8) echo "<b><font color=red>";?>MP <?php if ($t==8) echo "</font></b>";?></a></td>
<td width=100 class=h><a href="a3tops.php?t=10"><?php if ($t==10) echo "<b><font color=red>";?>Gold <?php if ($t==10) echo "</font></b>";?></a></td>
<td width=150 class=h><a href="a3tops.php?t=11"><?php if ($t==11) echo "<b><font color=red>";?>Last Visit<?php if ($t==11) echo "</font></b>";?></a></td></tr>
<?php
$i=0;
while ($data=@mssql_fetch_array($res))
{
$i++;
echo "
<tr align=center>
<td>".$i."</td>
<td>".$data['char']."</td>
<td>".$aClass[$data['class']]."</td>
<td>".$data['level']."</td>
<td>".$data['str']."</td>
<td>".$data['int']."</td>
<td>".$data['dex']."</td>
<td>".$data['vit']."</td>
<td>".$data['mana']."</td>
<td>".$data['HP']."</td>
<td>".$data['MP']."</td>
<td>".$data['gold']."</td>
<td>".$data['laston']."</td>
</tr>";
}
?>
</table>
</body>
</html>
Maybe will need "SELECT UNOIN" for tables charac0-charac#...