How to import csv files selected by user to database

前端 未结 1 1491
情书的邮戳
情书的邮戳 2020-12-22 04:39

I wonder how i can import csv files that selected by user to database using php.

is there any practical way on this ?

thanks

相关标签:
1条回答
  • 2020-12-22 05:13

    PHP has a function for this: fgetcsv(). You'll still have to write the loop and the code that inserts rows into the database however.

    $in = fopen('filename.csv', 'r');
    while (($row = fgetcsv($in, 10000, ',')) !== false) {
      mysql_query("INSERT INTO ....");
    }
    fclose($in);
    
    0 讨论(0)
提交回复
热议问题