使用php上传excel表格到mysql

我正在开发一个Web应用程序使用PHP和引导。上传Excel表是我的应用程序的要求之一。现在我部分实现它(从Excel表中提取数据),接下来的事情我想上传这些数据到数据库表但是失败了。这是我的代码

$file = fopen($filename, "r"); $row=1; while (($Data = fgetcsv($file, 10000, ",")) !== FALSE) { echo $Data[0]; } fclose($file); 

这里是$Data[0]的输出

在这里输入图像说明

我想用这些字段将数据存储在数据库表中。我可以如何实现这一点?

这里是一个你应该怎么做的示例代码。 细节可以在这里find。 Excel阅读器库将Handel大部分的忙碌为你

  ini_set("display_errors",1); require_once 'excel_reader2.php'; $data = new Spreadsheet_Excel_Reader("example.xls"); echo "Total Sheets in this xls file: ".count($data->sheets)."<br /><br />"; $html="<table border='1'>"; for($i=0;$i<count($data->sheets);$i++) // Loop to get all sheets in a file. { if(count($data->sheets[$i][cells])>0) // checking sheet not empty { echo "Sheet $i:<br /><br />Total rows in sheet $i ".count($data->sheets[$i][cells])."<br />"; for($j=1;$j<=count($data->sheets[$i][cells]);$j++) // loop used to get each row of the sheet { $html.="<tr>"; for($k=1;$k<=count($data->sheets[$i][cells][$j]);$k++) // This loop is created to get data in a table format. { $html.="<td>"; $html.=$data->sheets[$i][cells][$j][$k]; $html.="</td>"; } $html.="</tr>"; } } } $html.="</table>"; echo $html; echo "<br />Data Inserted in dababase"; ?>