The page structure is as shown in the picture above, and PHP is used in the background. If there are three records in the education experience, and they are submitted to the background when you click save, how should you handle them better? ?
If the front page can dynamically generate a new row, how to deal with the problem of name and other attributes between multiple rows? ?
Can you tell me a general idea? ?
For example, there are the following fields
Modify the original
For example, its ID is 123
Newly added
Set a variable
createdIndex = 0
New
Delete
Background processing
First question
Use array form when submitting on the front end:
The server traverses the data and saves it to the database.
Second question
name does not conflict, only id conflicts. Can you describe the problem in more detail?
1. The data submitted to the background is received directly by $_POST, and then traversed in a loop to verify the corresponding data. After passing the verification, it is stored in the database;
2. All attributes of the same field in the newly added row are the same;
The first option:
When you click submit, process the data you want through js (for example, format it into an array) and put it into a hidden field before submitting the form
The second option:
Do processing on the form element name It has been clearly stated above:
The third option: (similar to the second one)
First define the template for adding a new line
When adding a new row, clone tpl_xxx and put it in the corresponding place (such as the last row of the table)
Post-submission PHP processing