Hi,
I have a problem where the code below, which is used to grab rows from a mySQL table and put them into an XLS Excel file, is a bit broken in that it won't include the first row from the recordset.. it's there in the query and I can output it to the page, but soon as it goes into an XLS file, the first row gets dropped for some reason.. there's probably a problem with the logic and loops I'm using, but maybe someone else can see it where I can't. I got this code from: http://www.phpfreaks.com/tutorials/114/0.php
Thanks for the help!
Here's the code:
for ($x = 0; $x <= $num_rows; $x++) {
while ($row = mysql_fetch_row($result)) {
$line = '';
foreach($row as $n => $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
if ($n == "6" || $n == "8") {
if ($value == 0) {
$value = "No date set.";
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
} else {
$value = date("m/d/Y", $value);
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
}
$line .= $value;
}
$data .= trim($line)."\n";
}
}