I am trying to think of a query that will do what I am wanting, however it has got me stumped so figured I would pick some brains for ideas.
I have a excel file that is read and converted to a loop for each row and for each column.
There are about 5000 values on the excel file so there are a lot of loops happening, I am wanting it to query the database inside the second loop for the column code, and if there is a value inside my database that is not any of the codes it is looping it will delete it. And any codes that are in the loop but not on the database will be echo'd on the page.
I have the script working fine however its just structuring the query that I am confused about.
Any advice greatly appreicated, Simon
my code:
fileName = '2_1_2013_UPC_customer.xlsx';
$objPHPExcel = PHPExcel_IOFactory::load("2_1_2013_UPC_customer.xlsx");
include_once dirname(__FILE__) . ('/PHPExcel/Writer/Excel2007.php');
require_once dirname(__FILE__) . '/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load("2_1_2013_UPC_customer.xlsx");
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
$worksheetTitle = $worksheet->getTitle();
$highestRow = $worksheet->getHighestRow(); // e.g. 10
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$nrColumns = ord($highestColumn) - 64;
for ($row = 2; $row <= $highestRow; ++$row) {
for ($col = 0; $col < $highestColumnIndex; ++$col) {
$cell = $worksheet->getCellByColumnAndRow($col, $row);
$val = $cell->getValue();
$dataType = PHPExcel_Cell_DataType::dataTypeForValue($val);
if ($val == null) {
} else {
if ($col == 0) {
$name = $val;
}
if ($col == 2) {
$description = $val;
}
if ($col == 3) {
$reference = $val;
}
if ($col == 4) {
$weight = $val;
}
}
}
}