Retrieve name from SQL ID
#1

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?
Reply
#2

PHP код:
 SELECT Username FROM users WHERE ID id 
Reply
#3

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?
Reply
#4

Yes i know it's the same query but i don't know how to put it to show the message.
Reply
#5

PHP код:
new DB_Query[256], DBResult:Result;
format(DB_Querysizeof(DB_Query), "SELECT Username FROM Table WHERE UserID = '%d';"GarageInfo[Garageid][garageOwnerID]);
Result db_query(DbNameDB_Query);
new 
player_name[MAX_PLAYER_NAME+1];
if(
db_num_rows(Result))
{
    
db_get_field(Result0player_name24);
    
//The owner of this garage is %s (player_name)
}
else
{
    
//not found
}
db_free_result(Result); 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)