Top 10 Mysql.
#1

PHP код:
dcmd_top10(playerid,params[])
{
 
#pragma unused params
 
mysql_query("SELECT Exp, NAME FROM USERS ORDER BY Exp DESC LIMIT 10");
 
mysql_store_result();
 new 
output[512],username[24], scorevariable[5],tmpStr[64];
 while(
mysql_retrieve_row())
 {
 
mysql_fetch_field_row(username"NAME");
 
mysql_fetch_field_row(scorevariable"Exp");
 }
 
mysql_free_result();
 
format(tmpStrsizeof(tmpStr), "%s %d XP\n"usernamestrval(scorevariable));
 
strcat(outputtmpStr);
 
ShowPlayerDialog(playerid8DIALOG_STYLE_MSGBOX"players top10"output"OK""");
 return 
1;

And when i try it out it comes only 1 player with 0 XP?
Reply
#2

https://sampwiki.blast.hk/wiki/for#for

When you use your mysql_fetch_field_row, it tooks only the first statement it finds.
The first solution is to make an unoptimized query per player, the second one is to use a loop.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)