SA-MP Forums Archive
MySQL problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL problem (/showthread.php?tid=600721)



MySQL problem - Edw - 12.02.2016

Hello!
I have a little problem.
Find only the first id in the database, the restu is = 0.
I hope you understand me.

PHP код:
    format(szQuerysizeof(szQuery), "SELECT * FROM `accounts` WHERE `Clan` = '%d'"clanid);
    new 
Cacheresult mysql_query(mysqlszQuery);
    new 
idwtf[256];
    for(new 
icache_get_row_count (); != j; ++i)
    {
        
cache_get_field_content(0"ID"idwtf);
        
printf("%d"strval(idwtf));
    }
    
cache_delete(result); 



Re: MySQL problem - Sascha - 12.02.2016

You are running a loop and execute the same command each time.
You don't need to call the content of row "0" but of row "i"
Код:
    format(szQuery, sizeof(szQuery), "SELECT * FROM `accounts` WHERE `Clan` = '%d'", clanid); 
    new Cache: result = mysql_query(mysql, szQuery); 
    new idwtf[256]; 
    for(new i, j = cache_get_row_count (); i < j; i++) 
    { 
        cache_get_field_content(i, "ID", idwtf); 
        printf("%d", strval(idwtf)); 
    } 
    cache_delete(result);



Re: MySQL problem - Edw - 12.02.2016

Fixed