Mysql to sql.
#1

Is there any way to pass this code to sql?
Yes, my question is something stupid, but i do not know anything about mysql.

Код:
stock LoadTop10()
{ 
    new Query[128]; 
    mysql_format(mysql, Query, sizeof(Query), "SELECT * FROM `players` ORDER BY `score` DESC LIMIT 10 "); //not tested, might need to fix the query
    mysql_function_query(mysql, Query, 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
	{
		for(new i = 0; i < rows; i++) //loop through all the found rows and pull the following
		{
			new dest[24], score;
			cache_get_row(i, "pName", dest); //get all the player names pulled from the query
			score = cache_get_row_int(i, "score"); //pull all the scores from the rows retrived
			printf("top 10 players are %s wtih scores of %d", dest, scores); //print the result when ever LoadScores is called.
		}
        else
        {
            printf("There are no players saved with score.."); //if there were no rows found in the query called in LoadTop10
            //escape ect..
    }
	return 1;
}
Reply


Messages In This Thread
Mysql to sql. - by dani18 - 19.05.2018, 05:20
Re: Mysql to sql. - by 10MIN - 19.05.2018, 08:24
Re: Mysql to sql. - by Dayrion - 19.05.2018, 10:16
Re: Mysql to sql. - by GTLS - 19.05.2018, 10:19
Re: Mysql to sql. - by CodeStyle175 - 19.05.2018, 10:23
Re: Mysql to sql. - by dani18 - 19.05.2018, 14:40
Re: Mysql to sql. - by GTLS - 20.05.2018, 05:48
Re: Mysql to sql. - by dani18 - 20.05.2018, 15:44

Forum Jump:


Users browsing this thread: 2 Guest(s)