Php import order, about one order of multiple products

Source: Internet
Author: User
For more information about how to import orders using php, I use PHPExcel. the requirements are as follows: there are two types of Excel tables, the first is that a single order occupies one row regardless of the number of items, and the second is that a single order occupies several items. how can we store these two types of excel files in the database? You need to save the imported information to three tables.


Reply to discussion (solution)

Table structure design is very important. In fact, your two tables are order tables and order details.

The first type is that an order occupies a row regardless of the number of items (the order table records basic information, such as the customer name, address, phone number, and freight)
The second is that a single order has several items that occupy several rows (order list, record the specific item list)

You can also create these two tables in the database, obtain data through PHPExcel, and then insert the data into the table through mysql_query insert.

What does the landlord mean by saving three tables? As stated in #1, can an order table have an order list? When processing PHPExcel data, you can store basic information such as order ID in the order table, and then store the product information in the order to the order list according to the corresponding order ID?

Well, both of them are right. I am like this: at the time of import, some rows in the excel table contain a complete order information, and some rows have a complete order information, after being imported to a program, how can we determine the end of a complete order information when inserted to the database? This means how to determine if an order has three rows (three products) inserted into the database?

Do you want to read the content in the cell?
Isn't the description text used before each number?
It's impossible to have only numbers, right? Even so, you can read the data according to the agreed position.

This is the case. let me take a screenshot to illustrate my problem.

Lines 2nd and 3 are okay. look, lines 4, 5, and 6 are an order information. I imported the excel file into the program and put it in an array, printed out is incorrect. Rows 2nd and 3 indicate an order, and rows 4, 5, and 6 indicate an order. You can see that this is the problem I encountered. my QQ: 624843426 can help me analyze it later.

130721W2R7YX the A5 and A6 values should be read from A4.
Because the corresponding B4, B5, and B6 have values, the A4 value should be included in A5 and A6.
When will it end? When Annn and Bnnn have no or both values, it is over.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.