SQL Script

smoochy boys on tour

astral

Dedicated Member
Dedicated Member
Dec 14, 2012
109
3
45
Poland
Hi. Colleagues, will someone help in the SQL script?
I need to get TOP 10 from TBL_Reputation.

I wrote something like that:
<?php
include('00header.php');
include('adodb/adodb.inc.php');
include('00tohtmlnew.inc.php');
include('00connString.php');
GLOBAL $gSQLMaxRows,$gSQLBlockRows;
$gSQLMaxRows = 1000; // max no of rows to download
$gSQLBlockRows=1000; // max no of rows per table block

$conn = &ADONewConnection("ado_mssql");
if (@$conn->PConnect($gameDSN, "", "", "")) {
echo <<<END

END;

$recordSet = &$conn->Execute('Select TOP 10 FLD_CHARACTER, FLD_POINT FROM TBL_Reputacja');
if ($recordSet) {
if ($recordSet->EOF) {
print "Not Available";
} else {
rs2htmlnum($recordSet, 'BORDER=0', Array('Nick', 'Point'));
}
$recordSet->Close(); // optional
} else {
print "Not Available";
}

echo <<<END
</td><td align="center" valign="top" width="25%">
END;


END;

echo <<<END
</td></tr></table>
</td><td width="10"> </td><td align="left" bgcolor="#111">
<table border="0"><tr><td align="right"></td><td>
END;


$conn->Close(); // optional
} else {
print "Statistics is not available because the server is busy or down.";
}
?>

Everything works with the fact that the ranking is not by the number of points ;/

Bez tytułu.jpg
 

Violent

Drinker Of Tea
Golden Oldie
Oct 7, 2008
1,071
201
170
Sheffield, UK
Try this:

Code:
[COLOR=#3E3E3E]Select TOP 10 FLD_CHARACTER, FLD_POINT FROM TBL_Reputacja
Order by [/COLOR][COLOR=#3E3E3E]FLD_POINT  desc[/COLOR]

It will order your top 10 by the FLD_POINT value in decending order. So the highest points will be at the top.
 
Upvote 0

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
you need to order. That is just finding the top 10 records in the table, in the order they were added.

Code:
Select TOP 10 FLD_CHARACTER, FLD_POINT FROM TBL_Reputacja ORDER BY FLD_POINT DESC

Edit. meh, got there too slow.
 
Upvote 0

Violent

Drinker Of Tea
Golden Oldie
Oct 7, 2008
1,071
201
170
Sheffield, UK
you need to order. That is just finding the top 10 records in the table, in the order they were added.

Code:
Select TOP 10 FLD_CHARACTER, FLD_POINT FROM TBL_Reputacja ORDER BY FLD_POINT DESC

Edit. meh, got there too slow.

Nah not slow mate, just reinforces the answer I gave. Besides, you explained why it wasnt working in the first place. :smile:
 
  • Like
Reactions: zomvra
Upvote 0