How to Import CSV File Data Into Mysql Using PHP
If you are a developer then definitely you might have faced this. Many times you need to import data from a CSV (comma separated value) file and insert it into your MySQL database. Say for Example consider a case when you have many records in a CSV file and you need to import them into your MySQL database then you can’t insert each n every single record manually as it will take too much time. This case arises mostly when you want to import existing data in your website. In this tutorial I am going to explain you how easily you can do that. SQL query to create csvdata table: CREATE TABLE IF NOT EXISTS `csvtbl`( `ID` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `city` varchar(50) NOT NULL, PRIMARY KEY (`ID`) ) csvimport.php File Download File <?php //database connection details $connect = mysql_connect('localhost','root','123456'); if (!$connect) { die('Could not connect to MySQL: ' . mysql_error()); } //your ...