Re: Sending the results of a query without using a file
| From: | Richard Lynch | Date: | Wed, 02 May 2007 20:03:10 +0000 |
| Subject: | Re: Sending the results of a query without using a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254262@lists.php.net to get a copy of this message | ||
On Wed, May 2, 2007 2:17 am, Todd Cary wrote:
> Some shared servers do not allow the creation of a file, so I am
> looking for a way to take the results of a query (MySQL), create
> a CSV output and have it in a sendable format for the user
> without creating a file.
$result = mysql_query("select * from something");
$output = fopen('php://output', 'w') or die("I messed up the php://
bit");
header("Content-type: application/octet-stream"); //force download
while ($row = mysql_fetch_row($result)){
fputcsv($output, $row);
}
//Look ma, no file!
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?