Hi thanks for the reply. I think option B is best, however the output still appears the same. My updated code:
<?php
$host = "*********";
$user = "*********";
$pass = "*********";
$db = "database_name";
$table = "table";
$file = "member_information";
$link = mysql_connect($host, $user, $pass) or die("Cannot connect." . mysql_error());
mysql_select_db($db) or die("Cannot connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].",";
$i++;}
}
$csv_output .= "\n";
$values = mysql_query("SELECT userid AS \"UserID\",temp as \"\",field1 AS \"Name\",field2 AS \"HighSchool\",field3 AS \"HSGraduation\",field4 AS \"College\",field5 AS \"CollegeGraduation\",field6 AS \"Major\", field7 AS \"InternshipSite\",field8 AS \"Email\" FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].", ";
}
$csv_output .= "\n";
}
$filename = $file."_".date("m.d.y");
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("m.d.y") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
Any advice? Thanks!