It's kinda fuzzy what you want to do. One way to do that is to write to a database and sent it to the browser. I have an example portions used from binaries in database tut.
Here is my modified code with some comments I'm not sure if this works but should give a good idea. It basically runs a Select query that send back data and a mime header, if recognized by the system as text/html/image your browser will display. otherwise it will ask to save it. Optionally write the your output to the database. I'm kinda new to php/mysql so I might be barking up the wrong tree on what you want to do.. anyway heres my psudo code
<?php
$db = mysql_connect("localhost", "whygee", "12web12");
mysql_select_db("my_database",$db);
$tbl_MY_TABLE = mysql_query("SELECT COL_A, COL_B, COL_C from MY_TABLE",$db);
$outString = "***\r";
while ($myrow = mysql_fetch_row($tbl_MY_TABLE))
{
$outString .= "%s\r%s\r%s\r***\r, $myrow[0], $myrow[1], $myrow[2]";
}//end while
//this part you have probably seen before.
mysql_select_db("my_table_data", $db);
// the next portion is optional you can use this if you want to store the current info
// in a database
//I'm not sure how often or the size of your updates or if you wanted to keep a database
//with your log files or exactly your doing with these files.
//if you wanted too you could insert a new entry for everyday and just have people download that file
//for the particular day. so you may want to use a select query to see if the file exists
// If it does do an update of the filename. there are many possibilities
$query = MYSQL_QUERY("INSERT INTO my_table_data (bin_data,filename,filetype) ".
"VALUES ('$outputString','"my_table_data.txt'",'"text\plain"')");
//end optional
$query = "select bin_data,filetype from my_table_data where filename=my_table_info.txt";
$outputdata = MYSQL_QUERY($query);
Header( "Content-type: text\plain");
echo $outputString;
?>