Load Transaction from database to dialog -
djmckjuba - 06.03.2016
Hi i have problem... Please help me and sorry for english
I have bank system with transaction history , loading and save in database,one transaction = one string..
Have this
Save new string to database field "Transaction"... One string = one rows in field "Transaction"
new Query[200];
format(Query,sizeof(Query), "UPDATE `transactionbank` SET `Transaction` = concat(`Transaction`,'\nSome words') WHERE `Username` ='%s' LIMIT 1",Name(playerid));
mysql_query(Query);
Example in database
Transaction
--------------
string1
string2
This work is ok, but problem in loading
new Transaction[MAX_PLAYERS_EX][500];
Field ґTransactionґ in database set on VARCHAR(500)
if(listitem == 4)
{
new Query[500],string1[500];
format(Query, sizeof(Query), "SELECT `Transaction` FROM `transactionbank` WHERE `Username` ='%s' LIMIT 1", Name(playerid));
mysql_query(Query);
mysql_store_result();
new rows = mysql_num_rows();
if(rows == 1)
{
mysql_fetch_row_format(Query,"|");
sscanf(Query,"p<|> s[500]",Transaction[playerid]);
format(string1,sizeof(string1),"%s",Transaction[playerid]);
ShowPlayerDialog(playerid,D_BankTransaction,DIALOG _STYLE_LIST,"{61B1FF}Last Transaction",string1,"Ok","");
}
mysql_free_result();
}
Problem is...
Database "Transaction"
---------------------------
Some word
Loading ok but...
"Transaction"
----------------
Some word
Some word
Loading to dialog "Some" it is all... I use sscanf,mysql_fetch_field_row... But the problem persists... Why
I want to load the first 15 transactions in dialog
Thx for help and sorry this is my first posts,i can not use code window
Re: Load Transaction from database to dialog -
djmckjuba - 06.03.2016
Some help pls
Re: Load Transaction from database to dialog -
[XST]O_x - 06.03.2016
Print the query before it's performed, and print it after mysql_fetch_row_format, and paste the results here
Re: Load Transaction from database to dialog -
djmckjuba - 06.03.2016
Ok i have two results
printf("%s",Query);
mysql_fetch_row_format(Query,"|");
printf("%s",Query);
sscanf(Query,"p<|>s[500]",Transaction[playerid]);
printf("%s",Query);
1. In database
----------------
Some words
1.print - SELECT `Transaction` FROM `transactionbank` WHERE `Username` ='%s' LIMIT 1
2.print - with mysql_fetch_field_row - "words|" .. with sscanf - "Some words"
3.print - with mysql_fetch_field_row - "words|" .. with sscanf - "Some words"
2. In database
-----------------
Some words
Some words
1.print - SELECT `Transaction` FROM `transactionbank` WHERE `Username` ='%s' LIMIT 1
2.print - with mysql_fetch_field_row - "Some" ... with sscanf - "Som"
3.print - with mysql_fetch_field_row - "Some" ... with sscanf - "Som"
Re: Load Transaction from database to dialog -
djmckjuba - 06.03.2016
Make me script ?
1.Save strings to database
2.Load 15 last string from database