If php wants to save data in batches, we only need to use the SQL insertinto statement to save data in batches. if it is to update data, updateset can be used to complete the update. The operation method is very simple, the following are two examples. batch... if php wants to save data in batches, we only need to use the SQL insert into statement to save data in batches. If update set is used to update data, the update can be completed, the operation methods are very simple. below are two examples.
Batch data input
Design method:Submit multiple form records at the same time, set the same text domain name for each record, and then read and extract the data submitted by the form through the for loop on the form processing page, finally, add the data to the database one by one in the form of data.
Use the count () function to obtain the number of elements in the array. int count (mixed var );
Form submission page. the code is as follows:
Database Connection page, the code is as follows:
Form processing page, the code is as follows:
Batch update data
The while, list (), and each () functions are used to update data in batches. the list () function is used to assign values to multiple variables at a time. the code is as follows:
Form processing page, the code is as follows:
Summary: my friends will find that the two examples have something in common. One is that the form name of the form from is in the form of a counts [] array, in php processing, the accept page will use for or while for traversal. below I will give you a simple analysis of these two examples.
Counts []: This indicates an array in the form. if you have 10 forms, our name = counts [] indicates that all of them are the same array, once you know that this is an array, you will know why traversal is used.
For or while: because the form is an array, we can traverse the array and save the data. the following code:
While (list ($ name, $ value) = each ($ _ POST) {OR
For ($ I = 0; $ I