Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/4312-export-data-from-excel-to-mysql/
Share on other sites

[!--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]
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 table

DROP 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.