What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Help

PHP Help
Author: Message:
ipab
Veteran Member
*****

Avatar
Design Evolved

Posts: 1017
Reputation: 32
35 / Male / Flag
Joined: May 2004
O.P. PHP Help
So I'm in the final stages of finishing my project, and I am stumped on something. I figured there are enough PHP genii around here to give me a hand with this.

I am trying to output data from a table called data in mysql, to a tab delimited, text file. My problem is that the new line isn't being reflected. The tabs are, but no new lines :(

code:
            $q = "SHOW COLUMNS FROM ".TBL_DATA."";
            $result = $database->query($q);
            $i = 0;
            if (mysql_num_rows($result) > 0) {
            while ($row = mysql_fetch_assoc($result)) {
            $csv_output .= $row['Field']."\t";
            $i++;
            }
            }
            $csv_output .= "\n";
            $q2= "SELECT * FROM ".TBL_DATA." WHERE ListID = '$listingsort'";
            $values = $database->query($q2);
            while ($rowr = mysql_fetch_row($values)) {
            for ($j=0;$j<$i;$j++) {
            $csv_output .= $rowr[$j]."\t";
            }
            $csv_output .= "\n";
            }

            $filename = $file."_".date("Y-m-d_H-i",time());
            header("Content-type: application/octet-stream");
            header("Content-disposition: attachment" . date("Y-m-d") . ".txt");
            header( "Content-disposition: filename=".$filename.".txt");
            echo $csv_output;



I've tried everything I could think of/googling. I have no idea what is going wrong and any help would be much appreciated ;)
56656E692C 20566964692C 2056696369
10-19-2010 12:47 AM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: PHP Help
Use \r\n instead of \n only if you want to open the file on Windows.
10-19-2010 12:56 AM
Profile PM Web Find Quote Report
ipab
Veteran Member
*****

Avatar
Design Evolved

Posts: 1017
Reputation: 32
35 / Male / Flag
Joined: May 2004
O.P. RE: PHP Help
Damn... That would make a lot of sense :)
The simplest thing really. Thank you very much. I was going crazy with this.

This post was edited on 10-19-2010 at 01:00 AM by ipab.
56656E692C 20566964692C 2056696369
10-19-2010 12:59 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On