Best way to use data from MySQL in Construct 2

  • I am making a quiz game and I'm making an admin page where users may add new questions. Therefore a MySQL database is the best way to do it for me.

    Now I have a table for questions and another one for answers. Like this:

    tblQuestions

    questionID

    question

    level (the level of the question from 1-3)

    tblAnswers

    answerID

    answer

    correct (true/false for correct answer)

    questionID (the id for the question that the answer belongs to)

    What is the best (suggested) way to get these datas into Construct 2? Create a dynamic xml file from php? Import data into an array with AJAX?

    I made a static XML to try, and it worked fine, but as I wrote I need a dynamic way to get data from MySQL.

  • I use php (and AJAX)) to read and write to a MySQL database. There are tutorials that helped me get started.

    My php script builds a big string of records to send all at once, that I then parse in C2 using tokenat.

    The only part that was slightly tricky was figuring out that I had to urlencode the data to avoid trouble. And to escape and urlencode the data being sent back to write...

  • I use php (and AJAX)) to read and write to a MySQL database. There are tutorials that helped me get started.

    My php script builds a big string of records to send all at once, that I then parse in C2 using tokenat.

    The only part that was slightly tricky was figuring out that I had to urlencode the data to avoid trouble. And to escape and urlencode the data being sent back to write...

    Yeah, I watched some of those examples, but I will need a more advanced method than those I've seen since I need to use a multidimensional array.

  • AllanR, what php/MySQL tutorials did you find to be the most helpful? I'm a newbie and need to ramp up on this pretty quickly. Thx, Jefferson

  • Jalindso, same above question for you, if you don't min weighing in...

    Jefferson

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made a static XML to try, and it worked fine, but as I wrote I need a dynamic way to get data from MySQL.

    Nothing stops you from building a dynamic XML file from your PHP script. A DOMDocument should work wonders for this.

    See the docs here : http://it.php.net/manual/en/book.dom.php

    Once the document is finished, you can output it as an XML string using DOMDocument::saveXML.

  • I ended up with creating a dynamic XML from PHP. Then I imported it from URL.

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