How to use C3 to load text and images from a database

Get help using Construct 3!

Post » Thu Oct 05, 2017 7:47 pm

I intend to create an app with several interactive activities for children. For this I will use some layouts each one for a activity and each should load a image/graphic from a database. The problem is I never create a game that use a db until today and I believe that is better to use a db instead importing text and images to the C3, isn't? So I will need know the basic procedures: which DB to use, how to create this connection (Need I to use a plugin? Can I use a DB in app for mobile devices or just for web?) Could someone help me giving some information about this?

Thanks in advanced
B
74
S
14
G
4
Posts: 1,054
Reputation: 8,213

Post » Thu Oct 05, 2017 8:02 pm

Check out the following URL for examples of this:

http://simbucket.com/chemthinkserver/ch ... ex.html?as

In order to do it, you will need a webserver with a database. Most web hosting companies offer a php/mysql package for fairly low cost. I recommend not saving the images themselves in the database. Rather, store them as a file, then store the filename/URL in the database.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
61
S
22
G
27
Posts: 456
Reputation: 19,336

Post » Thu Oct 05, 2017 8:13 pm

cjbruce wrote:Check out the following URL for examples of this:

http://simbucket.com/chemthinkserver/ch ... ex.html?as

In order to do it, you will need a webserver with a database. Most web hosting companies offer a php/mysql package for fairly low cost. I recommend not saving the images themselves in the database. Rather, store them as a file, then store the filename/URL in the database.


Nice @cjbruce

Thanks for the indication. I will check it. I am a Hostgator client.

Is this project yours? Do you know if I can use this method in the mobile apps? Do you have a tutorial about this? I don't know how to start to use this solution.
B
74
S
14
G
4
Posts: 1,054
Reputation: 8,213

Post » Thu Oct 05, 2017 8:37 pm

RBuster wrote:
cjbruce wrote:Check out the following URL for examples of this:

http://simbucket.com/chemthinkserver/ch ... ex.html?as

In order to do it, you will need a webserver with a database. Most web hosting companies offer a php/mysql package for fairly low cost. I recommend not saving the images themselves in the database. Rather, store them as a file, then store the filename/URL in the database.


Nice @cjbruce

Thanks for the indication. I will check it. I am a Hostgator client.

Is this project yours? Do you know if I can use this method in the mobile apps? Do you have a tutorial about this? I don't know how to start to use this solution.


The project is entirely my own, though it is a port of a flash-based version written by another teacher.

It is set up in two parts:

1. A Construct 2 client - This exists on the user's device, and runs a big Construct 2 project. The C2 project makes AJAX requests to the server.
2. A php server running a mysql database - This consists of an Apache server which runs php scripts that I wrote. The php scripts contain database calls to the mysql database. All user information is stored on the database.

This method also works in mobile apps. I used to include ad requests to my own ad server. All you have to do in C3 is make a GET or POST request to the server from the C3 project via AJAX.

As far as getting started goes, I will try to put this in another reply.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
61
S
22
G
27
Posts: 456
Reputation: 19,336

Post » Thu Oct 05, 2017 8:46 pm

To get started, I recommend searching for "php" in the Construct 2 tutorials. Here is one that has the basics:

https://www.scirra.com/tutorials/4887/tracking-your-users-with-ajax-php-and-mysql

Keep in mind that these tutorials may have been written for an outdated version of php. php has gone through some major changes in the past four years to address some security vulnerabilities, so you will need to go to php.net to read through to see what is new.

It is also possible to set up all of your database tables entirely within phpmyadmin. When I was first learning, this was much more intuitive than starting with raw mysql code. Once the tables are set up, you can write php scripts that contain mysql code to create/read/update/delete.
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
61
S
22
G
27
Posts: 456
Reputation: 19,336

Post » Thu Oct 05, 2017 8:48 pm

cjbruce wrote:
The project is entirely my own, though it is a port of a flash-based version written by another teacher.

It is set up in two parts:

1. A Construct 2 client - This exists on the user's device, and runs a big Construct 2 project. The C2 project makes AJAX requests to the server.
2. A php server running a mysql database - This consists of an Apache server which runs php scripts that I wrote. The php scripts contain database calls to the mysql database. All user information is stored on the database.

This method also works in mobile apps. I used to include ad requests to my own ad server. All you have to do in C3 is make a GET or POST request to the server from the C3 project via AJAX.


I will give it a try, but I think it will be almost impossible according with my knowledge

As far as getting started goes, I will try to put this in another reply.


Thank you! I will really appreciate that.
B
74
S
14
G
4
Posts: 1,054
Reputation: 8,213


Return to How do I...?

Who is online

Users browsing this forum: Alon, trainstation and 0 guests