php codes goes like this[php]<?
$fcontents = file ('./spreadsheet.xls ');
# expects the csv file to be in the same dir as this script
for($i=0; $i<sizeof($fcon tents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode("\t", $line);
$sql = "insert into TABLENAME values ('".
implode("','", $arr) ."')";
mysql_query($sq l);
echo $sql ."<br>\n";
if(mysql_error( )) {
echo mysql_error() ."<br>\n";
}
}
?>[/php]// above is my code . it is working fine for comma separated values.But i am unable to work out with tab . and is not working for XLS file. my aim is to read Excel data into Mysql database.
thanks,
Anji
$fcontents = file ('./spreadsheet.xls ');
# expects the csv file to be in the same dir as this script
for($i=0; $i<sizeof($fcon tents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode("\t", $line);
$sql = "insert into TABLENAME values ('".
implode("','", $arr) ."')";
mysql_query($sq l);
echo $sql ."<br>\n";
if(mysql_error( )) {
echo mysql_error() ."<br>\n";
}
}
?>[/php]// above is my code . it is working fine for comma separated values.But i am unable to work out with tab . and is not working for XLS file. my aim is to read Excel data into Mysql database.
thanks,
Anji
Comment