Export simple excel data into MySQL using PHP Export simple excel data into MySQL using PHP database database

Export simple excel data into MySQL using PHP


Save this excel file as csv and run the following code with add your changings

$source = fopen('email.csv', 'r') or die("Problem open file");    while (($data = fgetcsv($source, 1000, ",")) !== FALSE)    {        $name = $data[0];        $email = $data[1];        mysql_query("INSERT INTO `table` (`name`,`email`) VALUES ('".$name."','".$email."') ");    }    fclose($source);


There is a Iibrary named PHPExcel. With this library you can easily parse any excel file. Or you can export your file as csv and will be easier for you. php has native functions to handle csv files. You can use fgetcsv() or str_getcsv().


Goto this link and download the php class that will read the excel file and return the array. This array will hold the all data written in excel file.

php excel reader

Its free...

You can also see the demo there.

I am already using it. Its definitely good.

Any other help on this you can freely ask to me.