MySQL Looping
#1

How would I go through all players and do an action. My current code looks like:

pawn Код:
new string[128], pNm[MAX_PLAYER_NAME], convert[50], var;
mysql_query("SELECT `name` FROM `players` WHERE `var1` > 1 AND `var2` != 1");
mysql_store_result();
while(mysql_fetch_row(pNm)) {
    format(string, sizeof(string), "SELECT `var1` FROM `players` WHERE `name`='%s'", playersName);
    mysql_query(string);
    mysql_store_result();
    mysql_fetch_row(convert);
    var = strval(convert);
    format(string, sizeof(string), "UPDATE `players` SET `var1`='%d' WHERE `name`='%s' AND `var2`!=1", var-45, pNm);
    mysql_query(string);
}
But that only does this to the first player it selects.
Reply


Messages In This Thread
MySQL Looping - by SuperViper - 11.12.2011, 17:54
Re: MySQL Looping - by GamingTurf - 11.12.2011, 17:58
Re: MySQL Looping - by SuperViper - 11.12.2011, 17:59
Re: MySQL Looping - by GamingTurf - 11.12.2011, 18:08
Re: MySQL Looping - by Kingunit - 11.12.2011, 18:09
Re: MySQL Looping - by SuperViper - 11.12.2011, 18:18
Re: MySQL Looping - by Hiddos - 11.12.2011, 18:21
Re: MySQL Looping - by SuperViper - 11.12.2011, 18:24

Forum Jump:


Users browsing this thread: 2 Guest(s)