Reputation: 21
I'm looking to allow users to upload an Excel or CSV file to MySQL for a contact management system. Need to be able to allow users to map their columns so that they are imported into the correct column in the table.
Anyone know of a good site or tutorial on this?
Upvotes: 0
Views: 1744
Reputation: 654
Check out "insert from infile". I haven't done anything dynamic like this, but I use it all the time for statically formatted reports.
You can read the first line of the report to map the columns.
This might help read an XLS: http://www.phpclasses.org/package/1919-PHP-Stream-wrapper-to-read-and-write-MS-Excel-files.html
Upvotes: 2
Reputation: 62894
I don't know of anything that you can pull off the shelf and use, but you should be able to whip something up pretty quickly.
Basically, get the uploaded file, grab the first line (use fgetcsv()). Then dynamically build a little form that displays the data from each column, associated with a dropdown to select the destination field.
Upvotes: 0