I figure out how to write all the entries from my database onto a text file.

Code:
header("Content-Type: text/plain");
header("Content-Disposition: Attachment; filename=test.txt");
header("Pragma: no-cache");
exit;
How do I modify the text file??
Each entries (or row) have 5 elements in it and there are multiple entries in my database.
How do I write each elements follow by a comma onto a text file? Each row in the database would have a new line in my text file as well.

tks