Create dynamic text file download using SQL data


#1

Hi,

I’m trying to create a plain text file download from data held on my SQL server.

Its simply going to be email addresses pulled from our marketing database.

On the download console i’m going to have a link that will open a new PHP page that will run the script that builds the data. This part works fine.

I’ve tried using a script that outputs the necessary headers to trigger a download in the browser. However, this would appear to be for physical files on the server.

I’m trying to effectivly create a plain text file download using a variable. I don’t want to create a physical file.

Does anyone have any ideas on what I can do?

Many thanks.


#2

If i understood u right u wanna have a php file wich is called like:
http://www.whatever.com/script.php?var=value
but calling it should make the browser open a download dialog and save a file like emailaddresses_value.txt

is that right?

for that u may use:
[php]
header(‘Content-Type: text/plain’);
header(‘Content-disposition: attachment; emailaddresses_’.$GET[‘var’].’.txt’);
[/php]
and then just echo the content.


#3

C’est Parfait!

Thats done the trick! Thank you so much for your help :D

P


#4

no prob
Q