you would simply do the following:
$fh = "/path/to/text/file.txt";
// Print header for file (simply for description of what each column is)
$file_text = "<ID><NAME><DATE>";
// Make the query
$query = "SELECT * FROM tablename";
// Send request to DB
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query . " . mysql_error());
// Dump Result into an Array
$result_array = mysql_fetch_array($result)
// Loop through array dumping all results into the $file_text variable
foreach($result_array as $row) {
$file_text .= "<$row[0]><$row[1]><$row[2]>\n";
}
$handle = fopen ("$fh", "w");
fwrite($handle,$file_text);
fclose($handle);
That should do it..
note: if you are using php3 you will need to use a while loop instead of foreach as foreach was introduced in php4