How do I Get Values from MySQL Database

Get help using Construct 2

Post » Sun Jun 22, 2014 1:52 am

Hi guys.

i want to get a single value to set in a Global Variable in my project from a specific field from my mysql database

i cant use MySql directly in Construct 2? so i need to use an external PHP file with the query on it?

ie.

- I want to select the last Score saved:
SELECT * FROM scores ORDER BY points DESC Limit 1

and i want to save that value into a Global Variable called LastScore...

how can i do that?

i dont understood very well how AJAX.LastData works :S

thanks
B
13
S
2
G
1
Posts: 28
Reputation: 960

Post » Sun Jun 22, 2014 9:52 am

yes, you'll need php/perl/anything else to query the MySQL database and then return the data. look up cgi scripts and you'll see lots of exaamples. you can then use ajax to query the script on your server and then parse the data.

just be aware that you will find it awkward to test as you need to have a server and get around the cross-site scripting issus.
B
7
S
3
G
1
Posts: 184
Reputation: 1,352

Post » Sun Jun 22, 2014 11:57 am

ill try this in localhost,i know php+mysql, it is just dont get very well ajax in C2 xD
https://www.scirra.com/tutorials/346/on ... -php-mysql

well, that was easy... lets see later when the game is published to try if it works in the play store with (of course with my own hosting) xD!
B
13
S
2
G
1
Posts: 28
Reputation: 960


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 42 guests