row from database to array or...

0 favourites
  • 5 posts
From the Asset Store
Match the rows with tofus to clear the rows before you pass the cook.
  • Hi everybody,

    I have a frustrating problem about how I can load a single row from my database in my array to set the different value in specific variable in construct2...or with a differen method...

    Actually, I can show in contruct2 all of the value from the row in the database like this:

    "10""100""300""10""300""...ecc

    or:

    '10'200'300'400... ecc,

    when I load in construct2 with AJAX, I don't know what I can do to use a single row for set all of the variable in construct2...

    somebody have some idea? construct2 can recognize a single value from "" for example?

    Thank you very much

  • I don't quite understand, but I usually use the separator "|" (without quotes) to separe values on the text, and then using a for loop I can pass this text values to the array using the tokenat to read each value.

  • from the php file, I can load a value from the database.

    when the php file generate the value, I can load in construct2 with AJAX and show the echo in my project.

    so, if I use "|", like:

    10 | 100 | 1 | 2 |

    how i can set the variable in construct2 like this:

    healt: 100;

    point: 1;

    level: 2;

    etc..? I don't know how i can do in construct2...

    thank you very much

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ribis - get the text you want with ajax, then separe a value that you want for each variables

    example:

    1? - Request a text "100|1|2|" from an url using Ajax

    2? - On Completed Ajax Request

       - Then set "Healt" variable value to tokenat(AJAX.LastData,0,"|")

       + set "Point" variable value to tokenat(AJAX.LastData,1,"|")

       + set "Level" variable value to tokenat(AJAX.LastData,2,"|")

  • Ribis - get the text you want with ajax, then separe a value that you want for each variables

    example:

    1? - Request a text "100|1|2|" from an url using Ajax

    2? - On Completed Ajax Request

       - Then set "Healt" variable value to tokenat(AJAX.LastData,0,"|")

       + set "Point" variable value to tokenat(AJAX.LastData,1,"|")

       + set "Level" variable value to tokenat(AJAX.LastData,2,"|")

    thank you, is working perfectly, with this I make my script better than before, but I have another question, if I have one text like this:

    100|20|0|0|0

    200|50|20|0|0

    90|10|20|20

    it's possible to organize the variable for the newline? I mean, with this I have to make 5 text and I made 5 different file in php... if I can use one text line for all of my variable will be perfect, because I will use just one file in php... I can use the same method for one line, but if in the future I add something in my database i need to edit all order, would be a little bit confused...

    Thank you very much again

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)