
Seth Watson - 2011-12-26 01:11:00
I have tried a few different methods to pass the parsed xlsx data to my db, but they are not working. This is what I have so far. I'm new to php so any help would be greatly appreciated. I have also tried with implode, but not working either. Thanks!
// attempt a connection
$con = mysql_connect('localhost', 'root', '');
mysql_select_db('testdb2');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// end connection
if (isset($_FILES['file'])) {
require_once "simplexlsx.class.php";
$xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );
list($cols,) = $xlsx->dimension();
foreach( $xlsx->rows() as $k => $r) {
if ($k == 0) continue; // skip first row
for( $i = 0; $i < $cols; $i++)
mysql_query("INSERT INTO table (prQty, prMode, prPrem, prComm) VALUES (?, ?, ?, ?)");
}
}
// close connection
mysql_close($con);