CSV Importer in MySQL
Furqan Aziz | 06 Sep 2013 | Tutorials
CSV importer is a PHP file which can help you to import all your data in MySQL Database using CSV File. Source File csv_importer.php is also available with this tutorial.
- Open your Dreamweaver or Notepad editor and create new PHP Page and name it import.php
- Now include csv_importer.php file in your page like below.
For Connecting MySQL Database please write following line
- include ( "csv_importer.php" );
Now choose your database like below
- $conn = @mysql_connect("localhost","root","password");
Now write below lines . you just need to provide your table name where you want to import data. leave all other lines as it is.
Now you have to set columns of table according to your CSV file Template
create new importer object for importing data
$c = new CSV_Importer;
display log errors at end
$c->log_errors = true;
skip the very first row in CSV file
$c->skip_top = true;
Type of Server (default MYSQL), you can also use this MSSQL and PGSQL
$c->server = MYSQL;
Database Table where File will be imported
$c->table = "yourtablename";
Here you will write csv file reference from which your data will be imported to Table
Now include csv_importer.php file in your page like below.
in the end you will close MySQL Connection
- $result = $c->import("Your_CSV_Name.csv",$conn);
Above tutorial is based on scriptbaba 2009 scripts. Now that website is not working so I write this tutorial for you. For more information please post a comment on Crewow Blog
© 2014 CreWow Network - All Rights Reserved.