Jump to content

[SOLVED] how to import excel file to mysql database


suma237

Recommended Posts

You can either upload your CSV to the server and read it that way or make a form where you can paste the code in.

 

You can also make an upload form if its something that tyou want to do regularly.

 

Once read you'd use explode() to put each row into an array then populate the table using loop.

 

To Export the CSV in Excel, go to File>Export then select CSV from the filetype box.  It'll make a standard text file.

Link to comment
Share on other sites

Yes but first you need to make a CSV file by exporting the Excel file.

 

Once you've made that CSV file as I said earlier...

 

You can either upload your CSV to the server and read it that way or make a form where you can paste the code in.

 

You can also make an upload form if its something that tyou want to do regularly.

Link to comment
Share on other sites

In Excel, "File" menu then "Save As..." then from the file requester, "select "Save as type" to be a CSV file.

 

OK here's some questions:

 

1. How many rows is in your Excel document?

2. Is this a one-off or will you want to do more than one?

3. If more than one, do you want to do this regularly or only once or twice?

Link to comment
Share on other sites

1. How many rows is in your Excel document?

more than 400

2. Is this a one-off or will you want to do more than one?

i am not able to understand now

3. If more than one, do you want to do this regularly or only once or twice?

regularly

 

 

Doubts--is the file extension is *.csv?

Link to comment
Share on other sites

Yes, the file is ".csv"

 

OK for a Excel document having that much data you might want to either upload the CSV file to the server or write an upload script.

 

Once the CSV file is on the server you need to go through it with a loop and explode() the line into an array. From there you can then build an INSERT query for MySQL to insert each row into the database.

 

But that's pretty much what I've already said.

Link to comment
Share on other sites

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.