Hiya
Any help on this would be awesome. It works and exports as it should but it always removes the first record.
Cheers.............
<?php require_once('Connections/ta.php'); ?>
<?php
mysql_select_db($database_ta, $ta);
$query_exportShipTo = "SELECT ta_sample_data.sampleID, ta_sample_data.fname, ta_sample_data.lname, ta_sample_data.minname, ta_sample_data.minCampus, ta_sample_data.address1, ta_sample_data.address2, ta_sample_data.address3, ta_sample_data.address4, ta_sample_data.postcode FROM ta_sample_data INNER JOIN ta_sample_isbn ON ta_sample_data.sampleID = ta_sample_isbn.sampleID WHERE (((ta_sample_data.state)='current')) GROUP BY ta_sample_isbn.sampleID ORDER BY ta_sample_isbn.sampleID ASC";
$exportShipTo = mysql_query($query_exportShipTo, $ta) or die(mysql_error());
$row_exportShipTo = mysql_fetch_assoc($exportShipTo);
$totalRows_exportShipTo = mysql_num_rows($exportShipTo);
//EXPORT - SHIP TO
$fp = fopen("as400_ship_to.txt", "w") or die("Couldn't create new file as400_ship_to.txt");
while($row_exportShipTo = mysql_fetch_row($exportShipTo)) {
$line = '';
foreach($row_exportShipTo as $value) {
if ((!isset($value)) OR ($value == "")) {
//$value = "\t";
$value = ",";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . ",";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);
$numBytes = @fwrite($fp, $data) or die("Couldn't write values to file! as400_ship_to.txt");
fclose($fp);
header("Location: export2.php");
mysql_free_result($exportShipTo);
?>