SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/03/2016, 01:37 PM   #1
djmckjuba
Little Clucker
 
Join Date: Jun 2010
Posts: 5
Reputation: 0
Default Load Transaction from database to dialog

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
djmckjuba is offline   Reply With Quote
Old 06/03/2016, 07:53 PM   #2
djmckjuba
Little Clucker
 
Join Date: Jun 2010
Posts: 5
Reputation: 0
Default Re: Load Transaction from database to dialog

Some help pls
djmckjuba is offline   Reply With Quote
Old 06/03/2016, 08:07 PM   #3
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,962
Reputation: 94
Default Re: Load Transaction from database to dialog

Print the query before it's performed, and print it after mysql_fetch_row_format, and paste the results here
[XST]O_x is offline   Reply With Quote
Old 06/03/2016, 08:35 PM   #4
djmckjuba
Little Clucker
 
Join Date: Jun 2010
Posts: 5
Reputation: 0
Default Re: Load Transaction from database to dialog

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"
djmckjuba is offline   Reply With Quote
Old 06/03/2016, 10:06 PM   #5
djmckjuba
Little Clucker
 
Join Date: Jun 2010
Posts: 5
Reputation: 0
Default Re: Load Transaction from database to dialog

Make me script ?

1.Save strings to database
2.Load 15 last string from database
djmckjuba is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop won't load stuff from database Ox1gEN Scripting Help 3 12/12/2014 02:32 PM
Why Won't This Load From A Database? Ox1gEN Scripting Help 3 03/10/2014 08:11 AM
Load Toys from database [HELP!] [REP] cuemur Scripting Help 0 13/03/2014 02:57 PM
Load properties from database BritishBoy Help Archive 0 18/06/2011 07:33 PM
Server crashes on Database load wiZaK Server Support 3 18/01/2009 04:12 PM


All times are GMT. The time now is 11:02 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.