How do I export data from an Excel sheet into a MySQL database? Is data to be inserted into different tables instead of a single table using the upload button from the PHP/HTML page?
-
-
Answer:
In Mysql workbench, you can create the table and then use the import button to import csv files.
Jason Loveman at Quora Visit the source
Other answers
First make sure you save your Excel file as CSV. Consider that you have data for serial no, name and course info. You wish to put them into tables. Here is a simple example code to do that: $source = fopen('student-info.csv', 'r') or die("Problem open file"); while (($data = fgetcsv($source, 1000, ",")) !== FALSE) { $sno = $data[0]; $name = $data[1]; $courses = $data[2]; mysql_query("INSERT INTO `stable` (`sno`,`name`) VALUES ('".$sno."','".$name."') "); mysql_query("INSERT INTO `coursetable` (`sno`,`courses`) VALUES ('".$sno."','".$courses."') "); } fclose($source);
Sushant Hiray
LOAD DATA LOCAL INFILE 'C:\\temp\\yourfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2); this may help
Bikash Dash
Export the file to a CSV. Then Upload if the table matches the structure of the CSV, you're done.If not, you'll need to upload the xls and use a server side language to parse it out and save it.
Bastien Koert
Related Q & A:
- How do I bind data to a ComboBox?Best solution by Stack Overflow
- How can I export a game to another PC?Best solution by Yahoo! Answers
- How can i export my contacts to a csv file?Best solution by Yahoo! Answers
- How can I earn from working at home without spending a single penny?Best solution by Yahoo! Answers
- How do i change my myspace music player back to a single music player?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.