03.07.2014, 09:04
Alright, basically I'm trying to loop through data from a SQLite table and insert the unique information from each. Ex:
Sheriff Nathan Henderson
Undersheriff Connor Adams
Deputy Sheriff II DeAndre Smith
But all I can seem to get is:
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson (And a bunch of other Sheriff Nathan Hendersons).
I've spent 5 hours trying to solve this issue with no success. Here's my code for it, there are no errors or warnings.
I am using SQLite if that is needed to be known. I will +rep the person who helps me solve this as it's driving me nuts!
Sheriff Nathan Henderson
Undersheriff Connor Adams
Deputy Sheriff II DeAndre Smith
But all I can seem to get is:
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson
Sheriff Nathan Henderson (And a bunch of other Sheriff Nathan Hendersons).
I've spent 5 hours trying to solve this issue with no success. Here's my code for it, there are no errors or warnings.
pawn Код:
case 5: //Employee Database
{
new DBResult:results;
new username[32], thirdstring[128], EmployeeDatabase[512];
new rank;
new test;
format(string, sizeof(string), "SELECT * FROM `Accounts` WHERE `Member` = '%d'", 1);
results = db_query(ServerDB, string);
if (db_num_rows(results) != 0)
{
printf("Returned %d rows", db_num_rows(results));
for(new rows=0;rows<db_num_rows(results);rows++)
{
format(username, 32, "%s", GetAccountString(results, "Username"));
rank = GetAccountInt(results, "Rank");
test++;
printf("Called %d times", test);
format(string, 128, FactionRank[1][rank]);
format(thirdstring, sizeof(thirdstring), "%s %s\n", string, username);
strcat(EmployeeDatabase, thirdstring);
}
ShowPlayerDialog(playerid, DIALOG_MDC_EMPLOYEES, DIALOG_STYLE_LIST, "Employee Database", EmployeeDatabase, "Select", "Back");
}
return 1;
}