get and set a number in a DB

0 favourites
  • 5 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • I want to have a single persistent number That does not refresh to a default value when the page is refreshed. I am hosting with goDaddy, and have set up a mySQL DB, and have read some tuts on how to work with it. I want to know how to get and set a number in this DB using C2.

  • Add ajax object to project

    Add event Ajax post and give tag name (tag ie posttoserver)

    Adress needs to be your php file (ie yourserver/yourfile.php, paramters added like "request=getdata&somekey=somevar")

    Catch $_POST[variable] (if($_POST[request]=="getdata")) with a request for data on the php end

    Have php on your server process mysql query based on post request

    echo mysl data in your php file

    This data is relayed back to your game/application

    Use event on request complete (tag ie posttoserver)

    This even and subs hold the variable AJAX.Lastdata, which is the information you have echoed in your php file.

    Do something with data :)

  • Or you can use WebStorage.SetLocal and GetLocal. But a DB has better longer persistency and you can access the data where as webstorage is client side.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you show me a capx for this where i can add one to a webStorage number when you push a button?

  • Actually I do just what you are looking for in my tutorial. The location of the tack is stored and retrieved from the mySQL database.

    Click Me

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