i new php. need import excel details mysql database in php. downloaded 2 files reader.php
& oleread.php
, save under wamp/www/folder
. when execute following code, server throw error
the filename samp.xls not readable
give solution recover problem. code is:
<html> <head> <title>save excel file details 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 students (sid,name) values ('$id','$name')"; $result_insert = mysql_query($sql_insert) or die(mysql_error()); $x++; } ?> </table> </body> </html>
the filename samp.xls not readable
first thing come mind php server cannot read excel file ..
wamp on windows, right-click excel file, , add read
property everyone
Comments
Post a Comment