MySQL Query - Advanced scripters
#1

Sup guys. I have a phone contacts kinda thing I'm working on. Basically, you add a contact, and then you can view all your contacts. I'm just wondering what the correct code is to do view all the contacts you have. The table setup is like: id, belongs_to, contact_name, contact_number.
Reply
#2

GStylez MYSQL plugin:
Top of the script:
pawn Код:
new
        id[MAX_PLAYERS],
        belongsto[MAX_PLAYERS],
        contactname[MAX_PLAYERS],
        contactnumber[MAX_PLAYERS];
Somewhere else:
pawn Код:
new query[128], playername[MAX_PLAYER_NAME], result[128];
GetPlayerName(playerid, playername, sizeof(playername));
format(query, sizeof(query), "SELECT * FROM `yourtable` WHERE `belongs_to` = '%s'", playername); // I assume belongs_to is the field of the guy who's typing the command to view his contact list.
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row_format(result))
{
     sscanf(result, "is[24]s[24]i", id[playerid], belongsto[playerid], contactname[playerid], contactnumber[playerid]);
}
mysql_free_result();
not tested.
Reply
#3

ddddddd
Reply
#4

pawn Код:
new
    query[128];
while(samp_mysql_fetch_row(query)) {
    //Data to get
}
Reply
#5

Worked. Love you <3
Reply
#6

I'm not familair with that plugin.
But you could try what Alby told you.

Edit: Saw your reply too late.
Reply
#7

Btw, when I add this into my script and compile, PAWNO tells me theres shit load of errors, for e.g., 'string already defined', when string is correctly defined in different commands, and not defined globally.

Quote:

new fields[20][45];

Reply
#8

Quote:
Originally Posted by DerrydBrincat
Посмотреть сообщение
ddddddd
A cunt raising his postcount
Reply
#9

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
A cunt raising his postcount
And what does that make you then? Right. Don't post if you have nothing useful to say.
@OP: I recommend using sscanf to split lines instead of split of explode. This is much faster and much easier to work with.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)