Re: CSV

From: Date: Wed, 22 Nov 2000 19:51:10 +0000
Subject: Re: CSV
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26683@lists.php.net to get a copy of this message
Sounds rather trivial. How about something like: $result = mysql_query('select * from blah'); $fp = fopen('/tmp/data.csv','w'); while(list($f1,$f2,$f3,$f4) = mysql_fetch_row($result)) { fputs($fp,"$f1,$f2,$f3,$f4\n"); } fclose($fp); The only thing you might have to add (depending on your actual data) is a way to deal with commas in your data. May be as simple as just putting each field in double quotes. -Rasmus On Wed, 22 Nov 2000, Chris Mason wrote: > I'm looking for an example of how to write the results of a query to a CSV > text file. > > > Chris Mason > Box 340, The Valley, Anguilla, British West Indies > Tel: 264 497 5670 Fax: 264 497 8463 > USA Fax (561) 382-7771 > Take a virtual tour of the island > http://net.ai/ The Anguilla Guide > Find out more about NetConcepts > www.netconcepts.ai > Talk to me in real time with Instant Messenger: masonc92@hotmail.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#26683) next »