I have an Oracle 11g database, being communicated to with PHP files. I want users on my website to be able to upload .xls documents, whose cell values will pass to the variables in the database.
I figure I will have the user upload the .xls via a basic html form, which seems the easiest. How can I have the data from an uploaded .xls file to update a database?
Note: The top couple of rows may have to be ignored because they will be titles/headings. How can I have the program ignore those?
Example Table:
TITLES AND OTHER HEADERS - Probably 2-3 rows of cells
Header1 | Header2 | Header3 | Header4 | Header5 | Header6 | Header7 | Header8
value1 | value2 | value3 | value4 | value5 | value6 | calue7 | value8
...
valueN | valueN | valueN | valueN | valueN | valueN | valueN | valueN
My current code:
Form:
<?php require "reader.php";
?>
<form name="SLCCA" action="update_handler2.php" method="post">
<u>GF:</u> <input type="file" name="xls_doc"><br>
<input type="submit" value="Submit">
Form Handler:
<?php
$xls_doc=$_POST["xls_doc"];
$objConnect = oci_connect("user", "pass", "(description=(address=(protocol=tcp)(host=hostaddress.com)(port=1533))(connect_data=(service_name=sid)))");
require_once('reader.php');
?>
<?php
$reader=new Spreadsheet_Excel_Reader();
$reader->setUTFEncoder('iconv');
$reader->setOutputEncoding('UTF-8');
$reader->read($xls_doc);
$strSQL = "LOAD DATA
INFILE 'xls_doc.dat'
BADFILE 'xls_doc.bad'
DISCARDFILE 'xls_doc.dsc'
APPEND
INTO TABLE INTOXDM.LCCR";
$objParse = oci_parse($objConnect, $strSQL);
$objExecute = oci_execute($objParse);
?>