Excel to MySQL

Status
Not open for further replies.


What Dave said :)
1. export to csv
2. create database
3. log into phpmyadmin
4. create table
5. click on table
6. click import
7. select file by clicking browse
8. Select CSV using LOAD DATA
9. Change Fields terminated by to a comma ,
10. Change Column names to your column names separated by commas.
 
You could go with the above, or you could also save as CSV, then a write a PHP script to process the CSV file in the following way:

Pull each line from the CSV file
Explode using "," as the delimiter
Use a standard MySQL query "INSERT INTO ...."

OR!

If you already have data in your table, you add a loop in there, for each row in your DB, check it against, the name or ID(the primary collumn in your Excel file) and if it DOES exist, Update the row, if it doesnt, insert into..

Really, it depends on the purpose, for me, updating credit cards every week, my method using a PHP script works very well because if the row exists it will update it, otherwise insert as new row...

If your looking to add that CSV file to the table one time, then im sure the PHPMyAdmin option is better..
 
thx for the input, i am using a combo of phpmyadmin and a little script i wrote to do what i need.
 
Status
Not open for further replies.