使用php将excel表导入mysql表

我想导入excel工作表数据到MySQL表与PHP,但我得到这些错误有人请让我从这..请看看PHP代码只忽略HTML的东西。

<?php include ("connection.php"); if(isset($_POST["submit"])) { $file = $_FILES['file']['tmp_name']; $handle = fopen($file, "r"); $c = 0; while(($filesop = fgetcsv($handle, 1000, ",")) !== false) { $name = $filesop[1]; $email = $filesop[2]; $sql = mysql_query("INSERT INTO co (name, email) VALUES ('$name','$email')"); $c = $c + 1; } fcose($file); if($sql){ echo "You database has imported successfully. You have inserted ". $c ." recoreds"; }else{ echo "Sorry! There is some problem."; } } ?> 

这是excel表单

在数据库中显示不同的格式

有库excellibrary/php-excel-reader/excel_reader2.phpexcellibrary/SpreadsheetReader.php

您可以使用这些库来读取您的内容并将其转换为数组。 将电子表格数据转换为数组后,可以使用迭代轻松地插入到数据库中。