Gnub Posted February 15, 2007 Share Posted February 15, 2007 Im wondering if it is at all possible, for PHP to create a CVS file from a mySQL database. If there is a simple mysql - go create a CVS file, and drop it <here> . Or will i have to go the long way round, and access the database, append each field in a record to a string, save the string to a file, and save it as a *.cvs file. Your thoughts here would be great. Cheers. Link to comment https://forums.phpfreaks.com/topic/38618-cvs-files-with-php/ Share on other sites More sharing options...
benjaminbeazy Posted February 15, 2007 Share Posted February 15, 2007 this will turn a table's data into csv in the format 'data', 'more date', 'more data' may want to use addslashes $sql = "SELECT * from table"; $result = mysql_query($sql); while($row = mysql_fetch_object($result){ $string = ""; foreach($row as $var => $val){ $string = $string."'".$val."', "; } echo "$string<br>"; } Link to comment https://forums.phpfreaks.com/topic/38618-cvs-files-with-php/#findComment-185342 Share on other sites More sharing options...
Gnub Posted February 15, 2007 Author Share Posted February 15, 2007 addslashes? sorry mate, no idea what that is. Link to comment https://forums.phpfreaks.com/topic/38618-cvs-files-with-php/#findComment-185358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.