1

私はphpが初めてです。Excel の詳細を PHP の MySQL データベースにインポートする必要があります。2 つのファイルをダウンロードし、 の下に保存しreader.phpます。次のコードを実行すると、サーバーは次のようなエラーをスローしますoleread.phpwamp/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>
4

2 に答える 2

0

なぜphpmyadminに直接インポートしないのですか?? ここをクリック

于 2013-07-15T06:17:06.917 に答える