Retrieve name from SQL ID - 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: Retrieve name from SQL ID (
/showthread.php?tid=664224)
Retrieve name from SQL ID -
SymonClash - 22.02.2019
In my account system i have
Player[playerid][ID]
Which is set as AUTO_INCREMENT to assign at every player an unique Account ID.
I also have the column "Username". (OBV).
My question is, how to retrieve username of the player by Account ID?
Re: Retrieve name from SQL ID -
Banditul18 - 22.02.2019
PHP код:
SELECT Username FROM users WHERE ID = id
Re: Retrieve name from SQL ID -
SymonClash - 22.02.2019
Oh ok thanks. Another question, what if i wanna show the garage owner's name in a message?
I wanted to do something like this:
"The owner of this garage is %s"
The column which stores the player's account ID as owner of the garage is GarageInfo[MAX_GARAGES][garageOwnerID]
How i can do it?
Re: Retrieve name from SQL ID -
SymonClash - 22.02.2019
Yes i know it's the same query but i don't know how to put it to show the message.
Re: Retrieve name from SQL ID -
Undef1ned - 22.02.2019
PHP код:
new DB_Query[256], DBResult:Result;
format(DB_Query, sizeof(DB_Query), "SELECT Username FROM Table WHERE UserID = '%d';", GarageInfo[Garageid][garageOwnerID]);
Result = db_query(DbName, DB_Query);
new player_name[MAX_PLAYER_NAME+1];
if(db_num_rows(Result))
{
db_get_field(Result, 0, player_name, 24);
//The owner of this garage is %s (player_name)
}
else
{
//not found
}
db_free_result(Result);