Although there are millions of tutorials about MySQL and PHP, I decided to make mine but in a very very simple way. Before you start, you must have a basic knowledge in MySQL.
Source code of PHP file connection
It is worth mentioning that we will not see good practices of databases, relationships, etc. We will use the tables as they are, without looking at normalization, or things like that.
Note: this tutorial uses PDO, but remember that we can also use mysqli functions. Personally I recommend PDO, because it is object oriented. However, I hope to write a tutorial about mysqli in the future.
Install web server and process PHP files: build a LAMPP stack on Android
This is not a post of those who use tricks to attract visitors, we are really going to install an Apache server on Android, configure it to process PHP files and finally write a Hello World: everything running from our mobile device.
Android mobile devices are not designed to be servers (although some of them are powerful), however it is always interesting to see how technology advances and day by day we can do more things with our phones.
Today we will see how to install the MySQL or MariaDB server on Android, thanks to the Termux application. For that it is enough to execute a few simple commands and voila, we will have a MySQL database server in our Android; fully functional and ready to execute queries.
If we want to put it for production, we can do it as long as we configure security. In short, we will not see more advanced topics; we will only see how to install mysql on Android.
Here we will use MariaDB and MySQL as synonyms; that is, if you see that I say MariaDB do not get confused, I mean MySQL; and vice versa.
I know that there are really more differences especially with the licenses, but that is another topic and you can search it in Google if you wish.
Today we will see how to install and configure Termux on Android, as well as a brief introduction to its use.
Termux is an application that will allow us to have a terminal on our device, but apart from that it gives us the possibility of installing very interesting packages; and if we configure them well and install well, we can have a complete and stable server on our mobile.
This application does not require root access, you only need that our Android phone has a recent version (I think it works from Android 6).