开发者

Upload Excel or CSV file to MySQL with PHP

开发者 https://www.devze.com 2022-12-26 17:27 出处:网络
I\'m looking to allow users to upload an Excel or CSV file to MySQL for a contact management syste开发者_如何学Pythonm.Need to be able to allow users to map their columns so that they are imported int

I'm looking to allow users to upload an Excel or CSV file to MySQL for a contact management syste开发者_如何学Pythonm. 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号