Want to Change Output to CSV

I want to change my script so that it outputs a comma separated text. Immediately below is what I started with, and below that is what I changed it to in order to get it to put CSV text in the email body.

I get an error stating that: Parse error: parse error, unexpected '\"' in in retention.php on line 81

well, if you can get all the records into an array, simply use implode() with commas as the delimiters to make a row. to make a CSV file, typically you'll need to change your content-type to text/plain or something similar and output newlines at the end of each row.

i'm not sure exactly what you're after here... any more explanation?

You can't win, you can't lose, you can't break even... you can't even get out of the game.

I tried sasa's example and that worked. Obsidian, I wasn't necessarily trying to create a CSV file, although someone is sure to ask for a CSV file next instead of the data in an email message, so thanks for that bit of advice.