PHP Classes

integrated with mysql insert

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in

      Native Excel Reader  >  All threads  >  integrated with mysql insert  >  (Un) Subscribe thread alerts  
Subject:integrated with mysql insert
Summary:convert to html then insert to msql
Author:kathy soebono
Date:2011-11-01 20:23:17

  1. integrated with mysql insert   Reply   Report abuse  
Picture of kathy soebono kathy soebono - 2011-11-01 20:23:18
need help with insert command to mysql, here's the code

require_once '';
require_once '';
$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?