Tiny SQL error I can't find?
#1

So I'm working on this dynamic faction system and I'm trying to list all factions, some weird reason it just lists the first column times the count of factions. I've tried debugging but I honestly can't see what I've done wrong?

Код:
mysql_tquery(mysql, "SELECT `fName` FROM `factions` ORDER BY `fID` ASC", "ListFactions", "i", playerid);
Код:
forward ListFactions(playerid);
public ListFactions(playerid)
{
    new count = 0, rows, fields;
    cache_get_data(rows, fields, mysql);
    printf("start of list");
    if(rows)
    {
    	printf("if rows:%i", rows);
	    new facname[MAX_FACTIONS][50], faclist[300];
	    while(count < rows)
	    {
	    	cache_get_field_content(0, "fName", facname[count], mysql, 255);
	    	format(faclist, sizeof(faclist), "%s%s\n", faclist, facname[count]);
	    	printf("facname:%s count:%i rows:%i", facname[count], count, rows);
	    	count++;
	    }
	    return ShowPlayerDialog(playerid, DIALOG_FACTION_LIST, DIALOG_STYLE_LIST, "List Factions", faclist, "Okay", "");
    } 
    else 
    {
    	SendErrorMessage(playerid, "There are no factions.");
    	return cmd_factions(playerid, "");
    }
}
Код:
[11:35:22] start of list
[11:35:22] if rows:3
[11:35:22] facname:Los Santos Police Department count:0 rows:3
[11:35:22] facname:Los Santos Police Department count:1 rows:3
[11:35:22] facname:Los Santos Police Department count:2 rows:3



(Don't comment on the variable sizes, those still need to be changed)
Reply
#2

If you know the number of iterations you should use a for-loop. But your actual problem is that you're always accessing row 0.
Код:
cache_get_field_content(0, ...
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
If you know the number of iterations you should use a for-loop. But your actual problem is that you're always accessing row 0.
Код:
cache_get_field_content(0, ...
I don't know what it was with me but I knew 100% you'd respond to my thread lol, thanks for the assistance. I'm going to change everything about it very soon, this was just a quick test phase.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)