Thank you very much, Bastien. It works great after a touch of tweaking.
But it insists on putting a .php at the end of the downloaded file name. So instead of downloading IBDdata.csv it downloads IBDdata.csv.php
Any idea how to fix that? My code is below.
The file it is in (all by itself) is download.php if that matters.
//////////////////////////////////////////////
$connID = connect_to_db();
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Cache-control: private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=IBDdata.csv");
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
$LocalFile = FOPEN("IBDdata.csv","w"); //open the local file for writing
$query_select = "SELECT date_format(entryDate , '%M %e, %Y'), entrySubject, entryAuthorFirst, entryAuthorLast, entryComments FROM tblData ORDER BY entrySubject";
$result = mysql_query($query_select, $connID);
IF ($result) // Makes sure there is data to get.
{
$query_select = "SELECT date_format(entryDate , '%M %e, %Y'), entrySubject, entryAuthorFirst, entryAuthorLast, entryComments FROM tblData ORDER BY entrySubject";
$result = mysql_query($query_select, $connID);
$count = mysql_num_fields($result);
WHILE($rows = mysql_fetch_array($result))
{
FOR($i=0; $i < $count; $i++)
{
ECHO $rows[$i].", "; //Writes the data line by line
}
ECHO "\n"; //new line
}
}
FCLOSE($LocalFile); //force the download
Many thanks,
Rauhnee