Create a Simple API In PHP with MySQL Database.
If you want to have a simple API with PHP/MySQL. This is a full guide for you.First you need to know, I did this project using a youtube video on this link. Also, you can follow steps here and use the code in the repository.
- Go to phpMyAdmin and Create a database. (e.g. simple_api_DB)
- Create a table and insert some data on it, or you can import the sql file avalable in sql directory in here.
- Create a php file. I made it on a 'src' directory.
- Create connection with database in a php file using: $mysqli = new mysqli("localhost","my_user","my_password","my_db");
- Test the connection.
- Add the code to fetch data and print as JSON.