Hi All
I have a table in my database full of addresses and I need to output it to a CSV file. I cant get it to work though.
Here is my code so far. Can anyone suggest whats wrong?
thanks
Aaron
I have a table in my database full of addresses and I need to output it to a CSV file. I cant get it to work though.
Here is my code so far. Can anyone suggest whats wrong?
Code:
<?
require_once('Connections/wp_data.php');
mysql_select_db($database_wp_data, $wp_data);
//$csv_output = '"column 1","column2"';
$csv_output = "\015\012";
$result = mysql_query("select * from addresses");
while($row = mysql_fetch_array($result)) {
$csv_output .= ''.$row[field1].','.$row[field3].','.$row[field6].','.$row[field7].','.$row[field8].','.$row[field9].','.$row[field10].','.$row[field11].','.$row[field13].','.$row[field14].','.$row[field5].',';
$csv_output .= "\015\012";
}
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv; filename=parcel_force_address_list_" . date("Ymd") .".csv");
print $csv_output;
exit;
?>
thanks
Aaron