Requesting a table from a custom website

Hello,

I’m kind of new into Programming and even newer (20 minutes) into trying to request data from a website. For example, I have a website, that (As I guess) must have a valid table with contents. And the question is, what params should get the exact value of the exact table from the website?

Let’s say that the website I have is customly made for my app and it only has a table with name > level > coins (example). And if many users use that, I would have many names with their own level and coin amounts.

The question is, what do I have to do in order to easily get data from a specified table part?

Thanks for help!

That is very vague…  

Normally you would use something like PHP and have a MySQL table to store your data. 

You would then issue a network.request() from your app to your PHP script (passing it some identifiers) and then your script would query the database and return the results as a JSON object which you then parse in your app to get the values.

Stack overflow has countless examples of this is so that would be a good starting point…

I’ll make sure to check it out. Thanks for a tip.

Okay, I’m starting to go mental after I tried to connect a MySQL database with Corona. I’m running a MySQL server on freemysqlhosting.net, I set up a database on phpmyadmin.co and created a table. And that’s where I’m absolutely stuck. I can’t find any useful information about “fetching” and “writing” anything into the table from a code. Please help.

Did you try Google?  https://www.w3schools.com/php/php_mysql_insert.asp

I recommend using PDO if your host supports it.

You will need some PHP script that runs on your server that will read your MySQL database and produce output that network.request() can take and turn into a useful Lua table. Generally speaking, you will get an associative array back from a MySQL query in PHP. This is very similar to a Lua table. PHP has the ability to convert an associative array to a JSON string with the json_encode() function. Your script would just use the PHP “echo” command to output the data. At that point it becomes the input to network.request()'s event.response entry. You would then use our JSON decoder (json.decode() to convert the event.response to a local table that you can use.

Rob

That is very vague…  

Normally you would use something like PHP and have a MySQL table to store your data. 

You would then issue a network.request() from your app to your PHP script (passing it some identifiers) and then your script would query the database and return the results as a JSON object which you then parse in your app to get the values.

Stack overflow has countless examples of this is so that would be a good starting point…

I’ll make sure to check it out. Thanks for a tip.

Okay, I’m starting to go mental after I tried to connect a MySQL database with Corona. I’m running a MySQL server on freemysqlhosting.net, I set up a database on phpmyadmin.co and created a table. And that’s where I’m absolutely stuck. I can’t find any useful information about “fetching” and “writing” anything into the table from a code. Please help.

Did you try Google?  https://www.w3schools.com/php/php_mysql_insert.asp

I recommend using PDO if your host supports it.

You will need some PHP script that runs on your server that will read your MySQL database and produce output that network.request() can take and turn into a useful Lua table. Generally speaking, you will get an associative array back from a MySQL query in PHP. This is very similar to a Lua table. PHP has the ability to convert an associative array to a JSON string with the json_encode() function. Your script would just use the PHP “echo” command to output the data. At that point it becomes the input to network.request()'s event.response entry. You would then use our JSON decoder (json.decode() to convert the event.response to a local table that you can use.

Rob