How to learn PHP and SQL on Android using Termux
PHP is a server scripting language and a powerful tool for making dynamic and interactive Web pages.
With PHP, you can connect and manipulate databases.
MySQL is the most popular database system used with PHP.
Learn PHP and SQL on Android using Termux
First of, we need to install the latest version of Termux and the latest version is 0.118.0
The latest version is not available in the Google Play Store. So, we will install it from F-Droid.
Because, Termux's official website recommends installing the latest version of Termux from F-Droid. As you can see in the picture below.
So, just go to F-Droid. You will see the F-Droid website as below. Now scroll down and click on the 'Download F-DROID' button to install F-Droid. Then we will be able to install the latest version of Termux.
You need to install F-Droid after downloading. Then, we will open it. After that, we will search Termux on Fdroid as below.
Then, click on Termux. As you can see in the picture above. Now install the latest version of Termux.
After installing Termux type the following commands one by one and press enter after typing each command...
- apt update command lets your system know which packages are available for upgrade, and where the software needs to be restored.
- apt upgrade -y can then act on this information and upgrade all installed packages to their latest versions.
- termux-setup-storage to allow Termux to access photos, media and files on your device.
- pkg install php to install the latest version of PHP.
- pkg install nano It's a editor. You can edit PHP file by this nano editor.
- nano filename.php to open a PHP file. Then, you can write PHP code to this file.
- php filename.php to run this PHP file.
- pkg install mariadb To install mysql. Mysql and Mariadb are the same thing.
- mysqld_safe -u root &
- mysql To run the mysql.
- CREATE DATABASE database_name; To create database.
- SHOW DATABASES; To show a list of databases.
- USE database_name; To run the database.
- CREATE TABLE table_name (id int(5), Name varchar(20), Email varchar(50)); Data is defined using SQL through CREATE statement.
- SHOW TABLES; To show a list of tables in the database.
- INSERT INTO table_name (id, Name, Email) VALUES(1, "Your name", "email address"); The INSERT command is used to enter one or more records.
- SELECT id, Name, Email FROM table_name; The SELECT statement is used to search the required information from the database. Data manipulation can be done using many more clauses with SELECT statement.
- UPDATE table_name SET Name = "Another name" WHERE Name = "Previous name"; The UPDATE command is used to update one or more records from the database.
- DELETE table_name WHERE Name="previous name"; The DELETE command is used to delete one or more records from database.