How to retrieve data from MySQL database using PHP ?
There are steps to understand for retrieving the data from the MySQL database.
- Create the database, then create the table for data.
- Enter the rows in the table. You have to connect to the database.
Now we understand each and every step as shown below.
Example 1: In this. we use PHPMyAdmin for the database handling. Start the server in the XAMPP as shown in the below image
Making sure that both Apache and MySQL are showing green color, means that the server is working.
After that create the database in the PHPMyAdmin. Open the below URL.
Create the table: Execute the SQL query in the “gfg” database.
CREATE TABLE student ( name varchar(20), branch varchar(20), roll_no INT );
INSERT INTO `student` ( `name`, `branch`, `roll_no`) VALUES ( 'Rohan', 'CSE', '1' );
After the data is inserted, the table will look like this.
PHP Code: Run the PHP script as shown below to fetch the data from the database.
My Personal Notes arrow_drop_up
Please Login to comment...