TAKE DATA FROM SQL
#1

Hey i have a sql database i want to take this:

Db is "Evo" ... table is "users" ... take "nick" where name is "jose"

and the "nick" show ir on and sendformatedtext

Any help :S? i need how to use and show data from sql
Reply
#2

Use sscanf (normal or 2.0, doesn't matter) and some variables. Here's an example:

pawn Code:
enum playeri
{
  name[24],
  cash,
  age
}
pawn Code:
new pinfo[MAX_PLAYERS][playeri];
pawn Code:
LoadData(playerid)
{
  MySQLCheck();
 
  new
    pName[24],
    query[61],
    line[100];

  GetPlayerName(playerid, pName, 24);
  mysql_real_escape_string(pName, pName);
  format(query, sizeof(query), "SELECT * FROM `users` WHERE nick='%s'", pName); // we check and get the gata from that name
  mysql_query(query);
  mysql_store_result(); // we store the result.
  mysql_fetch_row_format(line, "."); // we set a delimiter
  sscanf(line, "p.sdd", pinfo[playerid][name], pinfo[playerid][cash], pinfo[playerid][age]); // this will get the first 3 fields into pinfo[playerid][playeri]
  mysql_free_result();
}
Reply
#3

ok thx.. if i want to take Cash from table and show it on sendplayerformattedtext?
Reply
#4

help please
Reply
#5

how i can useee LoadData for give me for example information abaout "Cash" and send it on a formatted text? :S:S:S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)