28.06.2016, 10:33
We have created a system and I have a little problem when extracting the name of the player database.
I do not know how well I understand but so idea:
Debug:
Database:
I hope you understand.
I do not know how well I understand but so idea:
PHP код:
mysql_format(SQL, szQuery, sizeof(szQuery), "SELECT * FROM `aplicatii`");
result = mysql_query(SQL, szQuery);
for(new i, j = cache_get_row_count (); i != j; ++i) {
cache_get_field_content(i, "Userid",szResult); userid = strval(szResult);
cache_get_field_content(i, "Date", szResult); format(date, 256, szResult);
printf("%d | %s", userid, date);
format(szDialog, sizeof(szDialog), "%s\t%s\n", GetNameFromDB(userid), date);
strcat(szDialog2, szDialog);
Selected[playerid][x] = userid;
x++;
}
cache_delete(result);
stock GetNameFromDB(userid) {
new szQuery[256], Cache: result;
mysql_format(SQL, szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `id`='%d'", userid);
result = mysql_query(SQL, szQuery);
new szResult[256], szName[256];
format(szName, 256, "Null");
for(new i, j = cache_get_row_count (); i < j; i++)
{
cache_get_field_content(i, "username", szResult); format(szName, 256, szResult);
}
cache_delete(result);
printf("%s", szName);
return szName;
}
PHP код:
With GetNameFromDB(userid):
[12:35:06] 1 | 1
[12:35:06] Null
[12:35:06] 1 | 1
[12:35:06] Null
[12:35:06] 1 | 1
[12:35:06] Null
[12:35:06] 1 | 1
Without:
[12:12:15] 1 | 1
[12:12:15] 2 | 2
[12:12:15] 3 | 3
[12:12:15] 4 | 4
I hope you understand.