
 kathy soebono - 2011-11-01 20:23:18
need help with insert command to mysql, here's the code
<?php
require_once 'CompoundDocument.inc.php';
require_once 'BiffWorkbook.inc.php';
$fileName = 'excelfilename.xls';
if (!is_readable ($fileName)) die ('Cannot read ' . $fileName);
$doc = new CompoundDocument ('utf-8');
$doc->parse (file_get_contents ($fileName));
$wb = new BiffWorkbook ($doc);
$wb->parse ();
mysql_connect("localhost", "userdatabase", "passworddatabase") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
foreach ($wb->sheets as $sheetName => $sheet){
	for ($row = 0; $row < $sheet->rows (); $row ++)
	{
		for ($col = 0; $col < $sheet->cols (); $col ++)
		{			
			if (!isset ($sheet->cells [$row][$col])) continue;
			$cell = $sheet->cells [$row][$col];
$qry = "INSERT INTO tablename(field1, field2, field3, field4) VALUES('".$cell->value."')";
$result = @mysql_query($qry);
			echo $cell->value.'';			
		}
	}
}
?>
did i put something wrong with the code?
Thanks