Problem Description Usually we provide the user's data input interface, only one data can be entered at a time; if the user holds a large number of data on the hand, they will hope to "Presses" into our database. , Not a pen. CSV (Comma Separated Value) uses a comma as marks that are separated by each storage. In a CSV file, each information is expressed in a row, and each field value is separated from the comma, like this look: 91001, 1, Zhang 3, 850506, 723530091002, 2, Li Si, 850409, 723550691003, 3, Wang Wu, 841212, 7235987 Most counseling tables and database applications can make data to become CSV files. If your user already has a trial table (such as EXCEL) The data file is established, then he can put the information first into the CSV format file, and then put into your database. So how do you handle this CSV file? My approach has been prepared for you to prepare a ready-made CSV file. Please download it back, wait until you will use it. If you have not seen the CSV file content, you can use the text editor such as "Notepad" to open this file to see. In this CSV file, each column has five fields, named "SID", "SNUM", "Sname", "Birthday" and "Phone", the following examples are also designed for these five fields, May be different from your own situation. 1. Upload the CSV file First, you have to get the user upload the CSV file to the server on the server, you can try the following example. 2. After obtaining the contents of the CSV file to be uploaded by the user, we can use the fopen () to remove its content with the fgetcsv () function. Where $ csvfile is set to the previous example, you don't definitely be the same as me. When using the FGETCSV () function to remove the contents of the CSV file, one of the materials will be taken at a time, and the location is separated from the position, and the column is removed into one field, and it is back in an array. Take more CSV data above as an example, the first time I use $ ROW = FGETCSV ($ fp, $ csvfile_size), the return of $ row is an array, its content is: $ row [0]: 91001 $ row [1]: 1 $ ROW [2]: Zhang San $ ROW [3]: 850506 $ row [4]: 7235300 Therefore, we can read it in a list of the contents using the While recoil. $ fp = fopen ($ csvfile, "r"); while ($ row = fgetcsv ($ fp, $ csvfile_size)) {...} fclose ($ fp);?> in FGETCSV () The second parameter used is the length of the column. Since I didn't calculate the actual length of the column, I steal a lazy, replaced with $ csvfile_size, when I encountered an EOF or NewLine character, I automatically interrupt read. Actions. Also, if your CSV file is not a comma as a field interval, you can add a third parameter, specify the separator you want here. 3. Compose the SQL string to match the previous step, we combine the desired SQL strings in the WHILE ring. During the read, it is not processed when the empty data column is encountered.