To import data from csv to mysql we need to convert excel file data to csv file and then upload using front end page using php codeigniter framework.
Now we will move to coding part ,Here we need to create three files in codeigniter folders i.e
1) Model file
2) View file
3) Controller file.
Now In the first step we will create View file as Upload_csv.php under View folder.
Now in the second step we will create controller file as User.php under controllers folder.
Here we are uploading the csv file using upload_sampledata function.
Now in the third step we will create Model file as upload_services.php under Models folder.
In the above code i used fgetcsv($fp,1024) to get csv line count and stored in $csv_line variable. Now using for loop read the csv file data and storing in an array and passing to codeigniter default insert function as shown above.
To maintain good website for online money making ,just take good Virtual Private Servers, Built for Open Source Developers , Fully managed, lightning-fast, starting at $15/mo with 1GB RAM! , a developer running a complex application that requires instant scalability, or a designer wanting to give your clients’ sites maximum performance, then VPS hosting is just what you need!
Thank you for reading this article.