私はphpが初めてです。Excel の詳細を PHP の MySQL データベースにインポートする必要があります。2 つのファイルをダウンロードし、 の下に保存しreader.php
ます。次のコードを実行すると、サーバーは次のようなエラーをスローしますoleread.php
wamp/www/folder
ファイル名 samp.xls を読み取ることができません
この問題を解決するための解決策を教えてください。私のコードは次のとおりです。
<html>
<head>
<title>Save Excel file details to the database</title>
</head>
<body>
<?php
include 'db_connection.php';
include 'reader.php';
$excel = new Spreadsheet_Excel_Reader();
?>
<table border="1">
<?php
$excel->read('samp.xls');
$x=2;
while($x<=$excel->sheets[0]['numRows']) {
$id = isset($excel->sheets[0]['cells'][$x][1]) ? $excel->sheets[0]['cells'][$x][1] : '';
$name = isset($excel->sheets[0]['cells'][$x][2]) ? $excel->sheets[0]['cells'][$x][2] : '';
// Save details
$sql_insert="INSERT INTO students (sid,name) VALUES ('$id','$name')";
$result_insert = mysql_query($sql_insert) or die(mysql_error());
$x++;
}
?>
</table>
</body>
</html>