Quote:
Originally Posted by 10MIN
Yes, the SQL Query will work.
Btw, your code can be optimised to:
PHP код:
stock LoadTop10()
{
mysql_function_query(mysql, "SELECT * FROM `players` ORDER BY `score` DESC LIMIT 10 ", false, "LoadScores", "", ""); //init the load scores function with no cache
return 1; // returning the function true
}
public LoadScores()
{
new rows, fields;
cache_get_data(rows, fields, mysql); //returning all 10 players & all their rows/fields
if(!rows)//if there are rows to be retrived continue
{
printf("There are no players saved with score..");
return 1;
}
new dest[24], score;
printf("top 10:");
for(new i = 0; i < rows; i++) //loop through all the found rows and pull the following
{
cache_get_row(i, "pName", dest); //get the name of the player on the position i
score = cache_get_row_int(i, "score"); //get the score of the player on the position i
printf("#%d %s with %d", dest, score); //print the player on the position i name and score
}
return 1;
}
|
Dude, do you think this works
Код:
mysql_function_query(mysql, "SELECT * FROM `players` ORDER BY `score` DESC LIMIT 10 ", false, "LoadScores", "", "");
in sql?