Re: Output of MySQl sorted query to text or Word file.

From: Date: Fri, 06 Dec 2002 15:50:57 +0000
Subject: Re: Output of MySQl sorted query to text or Word file.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127266@lists.php.net to get a copy of this message
On Fri, 6 Dec 2002, Tim Ward wrote: > everything you need is here > > http://www.php.net/manual/en/ref.filesystem.php > > in particular fopen(), fputs(), fwrite(), etc. > > Tim Ward > http://www.chessish.com > mailto:timward@chessish.com I found all this and have worked on getting the file output and formated to my (actually my boss') liking. The text file gets formatted just fine when read in Linux but the newlines appear as blocks when viewing in Windows. I've included the scipt that reads and formats the output below. What do I need to use to create real linefeeds or new lines when viewing under windows? TIA, Ed <? include ("../global.php"); mysql_connect ($host, $user, $pass); mysql_select_db ($database); $count = 0; $fp = fopen("$ad_path/example.txt", "w"); $newline = "\n"; $space = " "; $dollar = "\$"; $ln = "-----------"; $br = "Page Break"; $result = mysql_query ("SELECT * FROM listings ORDER by area, price DESC"); if ($row = mysql_fetch_array($result)) { do { fputs($fp, $row['mls']); fputs($fp, $space); fputs($fp, $dollar); fputs($fp, number_format($row['price'], ",")); fputs($fp, $space); fputs($fp, $row['area']); fputs($fp, $newline); fputs($fp, $row['copy']); fputs($fp, $newline); fputs($fp, $newline); $count++; if ($count == 8) { fputs($fp, $ln); fputs($fp, $br); fputs($fp, $ln); fputs($fp, $nl); fputs($fp, $nl); $count = 0; } } while($row = mysql_fetch_array($result)); mysql_close(); fclose($fp); } ?>

« previous php.general (#127266) next »