you don’t need complicated while() structures with PDO …
// setup
$pdo = new PDO( ... );
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// query
$stmt = $pdo->query($sql);
foreach ($stmt as $row) {
// do something with each result row
}
The only real difference there is sticking the false at the start of the comparison. If I recall correctly, this is sometimes recommended in languages that use a single = sign to assign a value, and a double = sign for comparison, because if you make a typo and use a single = sign you’ll always get an error (as you cannot assign a value to false or true) rather than the alternative.
Ah ok thanks guys, the code below ran, but what is happening now is that the output is duplicated, so everything comes out as needed, but each line is duplicated.
Ye whats happening is that each line in the excel file is duplicating the fields, so you have the fields duplicating next to each other in the same line.