I need help with mysql functions - 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: I need help with mysql functions (
/showthread.php?tid=285507)
I need help with mysql functions -
brawrr - 24.09.2011
hello, i have a_sampmysql.inc with this natives
PHP код:
native samp_mysql_connect(server[], user[], password[]);
native samp_mysql_select_db(db[]);
native samp_mysql_query(query[]);
native samp_mysql_store_result();
native samp_mysql_fetch_row(line[]);
native samp_mysql_get_field(field[], value[]);
native samp_mysql_num_rows();
native samp_mysql_num_fields();
native samp_mysql_ping();
native samp_mysql_real_escape_string(src[], dest[]);
native samp_mysql_free_result();
native samp_mysql_strtok(dest[], separator[], src[]);
native samp_mysql_close();
how I can select all users from the table and show them in the sendcliendmessage?
my code
PHP код:
new query[64];
format(query, sizeof(query), "SELECT * FROM players WHERE member = 1");
samp_mysql_query(query);
samp_mysql_store_result();
for(new i; i < findmember?; i++)
{
format(string, sizeof(string), "Name %s",namefromdb?);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
please help me with this function, thx
Re: I need help with mysql functions -
Hiddos - 24.09.2011
You need to query it first and store it, like you did. Then you need to fetch all rows to get the names. Also, use SELECT name (Or whatever field name you use) as you only need the name:
pawn Код:
new query[64];
format(query, sizeof(query), "SELECT name FROM players WHERE member = 1");
samp_mysql_query(query);
samp_mysql_store_result();
while(mysql_fetch_row(query))
{
format(string, sizeof(string), "Name %s",query);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
samp_mysql_free_result();
Something like that should work.
Re: I need help with mysql functions -
brawrr - 24.09.2011
thx man, its work)
Re: I need help with mysql functions -
brawrr - 24.09.2011
how i can correctly get the more fields from a table and post him to the message?
PHP код:
format(string, sizeof(string), "Name %s | Rank %d",query,rank?);
SendClientMessage(playerid, COLOR_YELLOW, string);
thx!