I've read all the threads on the forum, and I still can't get output to csv to work the way i want.
the following works, but i have to rename in .csv in the save as window, i'm trying to get it to be .csv automatically.
also, I can't get the headers to work.
Thanks, for any help.
<?php
if (!$link = mysql_connect('usahnmws003.ahipc.eds.com', 'voip', 'voip'))
exit("Unable to make a connection to the database");
if (!mysql_select_db("Chad", $link))
exit("Unable to select the database");
$delimiter = ','; // delimiter is sometimes ; or | instead
$quote = ''; // quote is sometimes ' instead
$your_query="SELECT ServName, ServIP FROM BaseServInfo WHERE Comp = '".bofa."' ORDER by 'Date_Valid', 'Time_Valid' DESC";
$result = mysql_query($your_query) or die(mysql_error());
header("Content-type: text/csv");
while ($record = mysql_fetch_row($result)) {
$first = true;
$time = explode(':', $record[1]);
$record[1] = $time[0];
foreach ($record as $field) {
if (!$first) echo $delimiter;
$field = str_replace($quote, $quote.$quote, $field); // escape quotes
echo $quote.$field.$quote;
$first = false;
}
echo "\n";
}
?>