In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms. The advantage of this design is that you can directly modify the table in the form field in the database to implement the form field displayed on the page.
In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms. The advantage of this design is that you can directly modify the table in the form field in the database to implement the form field displayed on the page.
In the previous section (1) (2), we analyzed the dynamic implementation of form fields. That is to say, the form field or each space displayed on the page is not an html Tag. It loops through the Retrieved Data and judges dynamically generated forms.
The advantage of this design is that you can directly modify the table in the form field in the database to modify the form field displayed on the page. How can we store data records after the dynamic form is submitted?
First, let's take a look at the source data table of the form field and the Form Format of the page form:
Data Table:
Page display:
Obviously, the form fields displayed on the page are from the previous data table. There are the following problems:
How should the data of these forms be stored when a form is submitted?
1. Design a table containing 28 fields in the form field? However, this dynamic form field is designed to enable the form to change with different requirements.
If the field in the form field is deleted, the effect is not too great. If the field in the form field is added or modified, the field will be lost when the form is submitted to the database, in severe cases, program running errors may occur.
2. Use the vertical table method:
The vertical table is used for analysis as follows: resume a table that stores the form value. For example:
The core fields of the Table value in this form are fied_id and value.
In this way, each form field and value are stored as a record in the database when the form is submitted. Each form submission actually inserts multiple records into the table, and these records constitute a piece of data submitted at a time.
That is to say, the traditional horizontal storage of data is transformed into vertical storage. This solves the problems that cannot be solved by the first solution. This makes the design completely dynamic.
When displaying data, you only need to convert the vertical table to horizontal Display Based on the Set primary key (implemented by SQL statements)
Simply put, vertical table Storage solves the problem that dynamic data is not limited by the number of fields in the horizontal table.