Import CSV File Data in Mysql Using PHP Code

Prem Tiwari - - PHP Tutorial

This is the easy method to upload/import your csv file data in mysql table, using the simple php code. We are using the ( PHP-PDO ) for the communicates with mysql database.

Below is the easy and simple steps for using this code. Create a mysql table using the below code :

Create database table

Select your database and create a table seoreports with id, account_name, ranking, alerts, opportunities, pdf_report fields. Open SQL tabs in phpMyadmin and Copy paste below query to create table.

Html Code

Create index.php page and ad below code.

PHP Code using PDO

In the below code i have used PDO (PHP Data Object) to connect with database and import csv data in database table.


About: Prem Tiwari

Prem Tiwari is the founder of and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.

Tags: , , , ,