I need help with mysql functions
#1

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(querysizeof(query), "SELECT * FROM players WHERE member = 1");
samp_mysql_query(query);
samp_mysql_store_result();
for(new 
ifindmember?; i++)
{
    
format(stringsizeof(string), "Name %s",namefromdb?);
    
SendClientMessage(playeridCOLOR_YELLOWstring);

please help me with this function, thx
Reply
#2

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.
Reply
#3

thx man, its work)
Reply
#4

how i can correctly get the more fields from a table and post him to the message?

PHP код:
format(stringsizeof(string), "Name %s | Rank %d",query,rank?);
SendClientMessage(playeridCOLOR_YELLOWstring); 
thx!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)