<p>I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.</p>

<p>I have the e-mailing of the link, MySQL query, etc. covered.</p>

<p>How can I, when they click the link, have a pop-up to download a CVS with the record from MySQL? </p>

<p>I have all the information to get the record already. I just don't see how to have PHP create the CSV file and let them download a file with a .csv extension.</p>

To have it send it as a CSV and have it give the file name, use header():
http://us2.php.net/header
```
```
header('Content-type: text/csv');
header('Content-disposition: attachment; filename="myfile.csv"');
```
```
As far as making the CSV itself, you would just loop through the result set, formatting the output and sending it, just like you would any other content.