<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Export MySQL query results to CSV'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Mon, 20 May 2013 09:48:20 GMT</pubDate>
<item>
<title>ajaypillarisetti said on 9/8/09</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ i'm kinda new to php. i help run a competition with teams from schools all over the country. i've got a page that allows a user to select a variable [a specific school, in this case] from a dropdown. this variable is then part of a query that returns some results specific information about the number of teams from the selected school and outputs them to a table. I'd like to be able to export that same query to csv. Do you all have any thoughts on how I could do that? Thanks much. ]]></description>
<pubDate>Tue, 08 Sep 2009 18:54:45 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
<item>
<title>ajaypillarisetti said on 9/8/09</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ i'm kinda new to php. i help run a competition with teams from schools all over the country. i've got a page that allows a user to select a variable [a specific school, in this case] from a dropdown. this variable is then part of a query that returns some results specific information about the number of teams from the selected school and outputs them to a table. I'd like to be able to export that same query to csv. Do you all have any thoughts on how I could do that? Thanks much. ]]></description>
<pubDate>Tue, 08 Sep 2009 18:54:07 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
<item>
<title>stephenwashburn said on 8/31/09</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ @killy, if you want the results to be on the server instead of sent to the client you will want to use <a href="http://us2.php.net/manual/en/function.fopen.php">fopen()</a> and <a href="http://us2.php.net/fwrite">fwrite()</a> in order to write the contents to a local file (obviously the file/folder will need to be writable by whatever user you are running php as - I believe its generally the apache user, depending on your setup of course). ]]></description>
<pubDate>Mon, 31 Aug 2009 20:01:29 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
<item>
<title>killy said on 8/31/09</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ how to make exported stay on server?? ]]></description>
<pubDate>Mon, 31 Aug 2009 00:20:27 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
<item>
<title>nevbear666 said on 1/14/09</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ mysql_list_fields is deprecated...

i used this one instead:

[code]
mysql_query("SELECT fieldname1,fieldname2,fieldname3...,fieldnameN FROM table_name");
[/code] ]]></description>
<pubDate>Wed, 14 Jan 2009 02:28:28 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
<item>
<title>tylerhall said on 3/1/07</title>
<link>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</link>
<description><![CDATA[ <p>In some situations it might also be useful to force the user's browser to download the file. Adding these lines should do the trick.</p>

<pre><code>header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Disposition: attachment; filename = $filename");
header("Content-Length: " . strlen($out));
</code></pre>
 ]]></description>
<pubDate>Thu, 01 Mar 2007 12:05:26 GMT</pubDate>
<guid>http://snipplr.com/view/2234/export-mysql-query-results-to-csv/</guid>
</item>
</channel>
</rss>