ORDER BY SQL
#4

The idnex (index*) is wrong I think too. It will start: kill[0] but id[1] instead of 0. Make sure about the datatype as Vince said and then try:
pawn Код:
db_get_field_assoc (sys_result, "kills", sys_field, 20),
    kills [i] = strval(sys_field);
db_get_field_assoc (sys_result, "id", sys_field, 20),
    id [i] = strval(sys_field);
db_next_row (sys_result);
it works fine to me.

pawn Код:
// Output:
[15:48:06] rows: 9
[15:48:06] id 5, kills 3300
[15:48:06] id 6, kills 789
[15:48:06] id 4, kills 120
[15:48:06] id 3, kills 110
[15:48:06] id 2, kills 99
[15:48:06] id 1, kills 90
[15:48:06] id 0, kills 88
[15:48:06] id 7, kills 55
[15:48:06] id 8, kills 33
By the way, use LIMIT clause in the query because if you get more than 30 rows, it will exceed the array's indexes (out of bounds).

pawn Код:
sys_result = db_query (Database, "SELECT * FROM `players` ORDER BY `kills` DESC LIMIT 30"); // change to the top N you want.
Reply


Messages In This Thread
ORDER BY SQL - by Mr_Zlodei - 12.01.2014, 12:16
Re: ORDER BY SQL - by Vince - 12.01.2014, 12:29
Re: ORDER BY SQL - by Mr_Zlodei - 12.01.2014, 12:36
Re: ORDER BY SQL - by Konstantinos - 12.01.2014, 12:40
Re: ORDER BY SQL - by Mr_Zlodei - 12.01.2014, 12:45

Forum Jump:


Users browsing this thread: 1 Guest(s)