Please check out the below code.
$key = $_SESSION['order_nums'];
$sqll = "SELECT * FROM `money` WHERE `order` = :key";
$qq=$con->prepare($sqll);
$qq->bindvalue(":key", $key);
$qq->execute();
$excel2 = PHPExcel_IOFactory::createReader('Excel2007');
$excel2 = $excel2->load('nTest.xlsx'); // Empty Sheet
$excel2->setActiveSheetIndex(0);
$worksheet = $excel2->getActiveSheet();
$Cno = '7';
$COno = '7';
$MSno = '7';
$CHno = '7';
$ALno = '7';
while($fdata=$qq->fetch(PDO::FETCH_ASSOC))
{
$totalCost += $fdata['cost'];
/*
$worksheet
->setCellValue('A' . $Cno++, $fdata['code'])
->setCellValue('D' . $COno++, $fdata['cost'])
->setCellValue('E' . $MSno++, $fdata['time'])
->setCellValue('F' . $CHno++, $fdata['hourly'])
->setCellValue('G' . $ALno++, $fdata['ot']);*/
}
Ok, so the part of the code where it says $totalCost += $fdata['cost']
is saying its a undefined variable. Yet the code below it that I commented out.. If I uncomment it, it works perfect.