Whaih Posted March 7, 2006 Share Posted March 7, 2006 Hi there,I'm new to php and i have trouble exporting data from Excel to MySql. There are available software application in the market that is able to do this but i would like to try it by coding in PHP. I know that i need to export the data to a csv file first before i put it in MySql. However i absolutely no idea where and how to start. Are there any kind soul to guide me along or are there any available sample coding for me to reference? Quote Link to comment https://forums.phpfreaks.com/topic/4312-export-data-from-excel-to-mysql/ Share on other sites More sharing options...
freddixon Posted March 7, 2006 Share Posted March 7, 2006 [!--quoteo(post=352442:date=Mar 7 2006, 10:31 AM:name=Whaih)--][div class=\'quotetop\']QUOTE(Whaih @ Mar 7 2006, 10:31 AM) [snapback]352442[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi there,I'm new to php and i have trouble exporting data from Excel to MySql. There are available software application in the market that is able to do this but i would like to try it by coding in PHP. I know that i need to export the data to a csv file first before i put it in MySql. However i absolutely no idea where and how to start. Are there any kind soul to guide me along or are there any available sample coding for me to reference?[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/4312-export-data-from-excel-to-mysql/#findComment-15001 Share on other sites More sharing options...
freddixon Posted March 7, 2006 Share Posted March 7, 2006 Hi,The easiest way is to create an SQL script file and then run it in one of the mysql clients such as mysqladministrator.The following example is very simple but should give you the idea. This part creates the database tableDROP TABLE IF EXISTS `database_name`.`table_name`;CREATE TABLE `table_name`.`Types` ( `Type_ID` INT(10) NOT NULL, `Type_Name` VARCHAR(25) NULL, PRIMARY KEY (`Type_ID`);)This second part inserts the data into the database table, it is this bit that you have created from excel.INSERT INTO `database_name`.`table_name`(`Type_ID`, `Type_Name`)VALUES (1, "Dogs"),(2, "Cats"),(3, "Pigs"),(4, "Donkeys");Hope this helps,Fred Quote Link to comment https://forums.phpfreaks.com/topic/4312-export-data-from-excel-to-mysql/#findComment-15007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.