PHP Classes
elePHPant
Icontem

Import Excel CSV into MySQL table: I want to import CSV file to MySQL table

Recommend this page to a friend!
  All requests RSS feed  >  Import Excel CSV into MySQL table  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

Import Excel CSV into MySQL table

Edit

by RAJESH BHATT - 4 years ago (2015-07-17)

I want to import CSV file to MySQL table

This request is clear and relevant.
This request is not clear or is not relevant.

+1

I have tables in MySQL database. This is the structure of my database tables:

table 1 - tbl_main_categories:

column(id,category_name)
values(1,jewellery)
values(2,earrings)

table-2(tbl_sub_category)

column(id,main_category_id,sub_cat_name)
values(1,1(from table tbl_main_categories),fine jewellwry)
values(2,1(from table tbl_main_categories),cutting jewellwry)
values(3,2(from table tbl_main_categories),sea earing)

table-3(tbl_products)

column(id,product_name,sub_category_id)
values(1,product1,2(from table tbl_sub_category))
values(2,product2,3(from table tbl_sub_category))
values(3,product3,2(from table tbl_sub_category))

My excel sheet data as follows(product.xls)

row-1

col1->product_name=product4.
col2->sub_category=cutting jewellwry

row-2

col1->product_name=product5.
col2->sub_category=sea earing

row-3

col1->product_name=product6.
col2->sub_category=finejewellwry

row-4

col1->product_name=product7.
col2->sub_category=sea earing

My problem:

How to import file product.xls to MySQL table (tbl_products), as it contains ids from table tbl_sub_categories where as in my Excel there is name of sub_categories?

Please suggest me a library as I am beginner to PHP world.

Ask clarification

1 Recommendation

Quick CSV import: Import CSV data into a MySQL database table

This recommendation solves the problem.
This recommendation does not solve the problem.

+3

by Manuel Lemos Reputation 17755 - 4 years ago (2015-07-20) Comment

You can use this class if you export your Excel spreadsheet to the CSV format.

It is important that the spreadsheet headers match the database field names.


Recommend package
: 
: