now the project needs to write an API to write the data from the txt file to the database. The txt file format is as follows:
1 Test data-English
2 Test data 2 chinese
3 Test data 3 American
now insert
$conn = mysql_connect after modification with the following code. Mysql_error ());
mysql_select_db ("test", $conn) or die ("Invalid query:". Mysql_error ());
$content = file_get_contents ("serial_number.txt");
$contents= explode (",", $content);
foreach ($contents as $k = > $v)
{
$id = $k;
$serial_number = $v;
mysql_query ("insert into serial_number ( id
, serial_number
)
VALUES("$id","$serial_number")");
}
there is no problem when inserting a small amount of data, but if 300000 of the data does not seem to be very good, I would like to ask for leave. Do you have a better way