• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] TOP 10 MySQL list
#1
Heart 
Hey, I was wondering if someone could help me out writing a code for displaying TOP 10 players by a parameter, for example top 10 with highest score.
I know how to do it in the oldest MySQL, but I havent been around for some time and can't figure out how to do it with the newest version.
This is my old code
Code:
mysql_query("SELECT `Score` ,`User` FROM `table` ORDER BY `Score` DESC LIMIT 10"); mysql_store_result(); new id,output[600], str[64]; while(mysql_retrieve_row()) {     id ++;     new username[24], scorevariable[5];     mysql_fetch_field_row(username, "Username");     mysql_fetch_field_row(scorevariable, "Score");     format(str,sizeof str, "%i. %s - %i score\n",id,username,strval(scorevariable));     strcat(output, str); } mysql_free_result(); ShowPlayerDialog(playerid,1945,0,"Score top list",output,"Close","");
  Reply
#2
PHP Code:
CMD:check(playerid) { mysql_tquery(mysql, "SELECT `Score`, `User` FROM `table` WHERE `Score` != 0 ORDER BY `Score` DESC LIMIT 10", "ShowTOP10", "d", playerid); } forward ShowTOP10(playerid); public ShowTOP10(playerid) { if(!cache_num_rows()) return 0; new output[600]; static username[MAX_PLAYER_NAME]; for(new i, num = cache_num_rows(); i < num; i++) { cache_get_value_name(i, "Username", username); cache_get_value_name_int(i, "Score", scorevariable); format(output, sizeof(output), "%s%i. %s - %i score\n",output, i+1, username, scorevariable); } return ShowPlayerDialog(playerid,1945,0,"Score top list",output,"Close",""); }
  Reply