<h2 style="color:#2641A1;
margin-left:auto;margin:20px auto 20px auto;
font-weight:bold;">SMS Ranking:</h2>
<table align="center" width="375" cellpadding="0" cellspacing="0" border="1">
<tr style="text-align:center;font-weight:bold;color:#2641A1">
<td style="width:16px">#</td>
<td style="width:76px">Account</td>
<td style="width:97px">GSM Number</td>
<td style="width:87px;color:green">SMS count</td>
</tr>
<?
$db_serv = '127.0.0.1';
$db_user = 'sa';
$db_pass = 'password';
$db_name = 'MuOnline';
$conn = mssql_connect($db_serv, $db_user, $db_pass);
if($conn) {
mssql_select_db($db_name);
mssql_query("IF NOT EXISTS(SELECT * FROM sysobjects
WHERE id = object_id(N'[dbo].[SMS_LOG]') AND
OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[SMS_LOG]
(
[memb___id] [varchar] (50),
[gsmnum] [varchar] (50),
[smscount] [int] );");
$res = mssql_query("SELECT memb___id, gsmnum, smscount
FROM SMS_LOG ORDER BY smscount DESC");
$pos = 1;
while($row = mssql_fetch_object($res)) {
$account = $row->memb___id;
$gsmnum = substr($row->gsmnum, 0, 10)."**";
$smscount = intval($row->smscount);
echo '<tr>
<td width="20" align="center">'.$pos.'</td>
<td width="90" align="center">'.$account.'</td>
<td width="150" align="center">'.$gsmnum.'</td>
<td width="80" align="center">'.$smscount.'</td>
</tr>';
$pos += 1;
}
}
?>
</table>