I have a webpage that has some very simple code..

<?php do { ?>
<?php echo $row_rstest['InvoiceNo']; ?><br>
<?php echo $row_rstest['CustomerName']; ?><br>
<?php echo $row_rstest['AKA']; ?><br>
<?php } while ($row_rstest = mysql_fetch_assoc($rstest)); ?>

Very simple repeat that gives me a nice clean list down the page .... Thus

1000.001
AVON RUBBER PLC.
AVON
1000.002
AVON RUBBER PLC.
AVON
1001.001
AVON RUBBER PLC.
etc...
etc...

Exactly what I need...

Here's the question, and I'm probably missing something simple.

I need a text file from that, exactly as is on the screen preferably with a forced download.

Any ideas would be much appreciated..

If you look at <a href="http://oasdb.net/system/test.php">Test</a>

I have tried all the various php such as.

<?php
header("Content-Type: text/plain");
header("Content-Disposition: Attachment; filename=test.txt");
header("Pragma: no-cache");
?>

but I either get all the text in line with the HTML tags, I just want the text displayed in the way it is displayed on the screen.

I hope this make more sense now.

Thanks

Andrew

    A) Don't put the html tags in when producing the output for text file.
    - OR -
    😎 use [man]strip_tags[/man] to pull out all the html tags before outputting for text download.

      Derokorian;11046479 wrote:

      A) Don't put the html tags in when producing the output for text file.
      - OR -
      😎 use [man]strip_tags[/man] to pull out all the html tags before outputting for text download.

      So how do I create a <br> type effect in php, because I'm getting the text file and the contents in one long line?

      Thanks

        Thank you for all your help...

        all working, end code was very simple..

        A couple of headers..

        header("Content-Type: text/plain");
        header("Content-Disposition: Attachment; filename=test.txt");

        Then this code produces the replication in a text file I needed.

        <?php do { ?>
        <?php echo "This is the invoice No." . "$row_rstest[InvoiceNo]\r\n" . "$row_rstest[CustomerName]\r\n" . "$row_rstest[AKA]\r\n" . "$row_rstest[Fe]\r\n"; ?>
        <?php } while ($row_rstest = mysql_fetch_assoc($rstest)); ?>
        <?php

        Thank you

          would be even simpler if you stripped all intermediate php tags. Also, having them there will output extra newline characters, because

          <php ?>
          <?php
          

          contains one newline, between first closing and second opening php tags.

            johanafm;11046513 wrote:

            would be even simpler if you stripped all intermediate php tags. Also, having them there will output extra newline characters, because

            <php ?>
            <?php
            

            contains one newline, between first closing and second opening php tags.

            This is why I didn't suggest adding any new lines in my solution. However, I think this may be running on *nix and viewed on windows, which isn't smart enough to display a new line when it encounters a \n without \r in front.

              Derokorian wrote:

              ...viewed on windows, which isn't smart enough to display a new line when it encounters a \n without \r in front.

              Well, Notepad isn't (Notepad isn't much more than this). A real text editor would be smart enough....

                Nice, so one php to open one to close...

                here's the end result...

                <?php
                require_once('../Connections/OASDB.php');
                require_once('../Connections/TextFile.php');
                $FileNameComp = $row_rstest['AKA'];
                $FileNameInN = $row_rstest['SnPf'];
                header("Content-Type: text/plain");
                header("Content-Disposition: Attachment; filename="."$FileNameComp"."_"."$FileNameInN".".txt");
                echo "FILEREV:1.03\r\n" . "CSINRID:11\r\n" . "LEVEL00:0\r\n" . "LEVEL0:1\r\n" . "LEVEL1:2\r\n" . "LEVEL2:3\r\n" . "LEVEL3:4\r\n" . "LEVEL4:5\r\n";
                do {
                echo "UNITID#:" . "$row_rstest[Unit]\r\n" . "UNITDESC:" . "$row_rstest[Component]\r\n" . "AREADESC:" . "$row_rstest[Lubricant]\r\n" . "SAMPLEID:" . "$row_rstest[InvoiceNo]\r\n" . "TAKEDATE:" . "$row_rstest[DateSampled]\r\n" . "RECVDATE:" . "$row_rstest[DateReceived]\r\n" . "REPTDATE:" . "$row_rstest[DateTested]\r\n" . "COMMENTS:" . "$row_rstest[Comments]\r\n" . "COMMENTS:" . "\r\n" . "COMMENTS:" . "\r\n" . "COMMENTS:" . "\r\n" . "FE:" . "$row_rstest[Fe]\r\n" . "CR:" . "$row_rstest[Cr]\r\n" . "AL:" . "$row_rstest[Al]\r\n" . "CU:" . "$row_rstest[Cu]\r\n" . "PB:" . "$row_rstest[Pb]\r\n" . "SN:" . "$row_rstest[Sn]\r\n" . "NI:" . "$row_rstest[Ni]\r\n" . "MN:" . "$row_rstest[Mn]\r\n" . "TI:" . "$row_rstest[Ti]\r\n" . "AG:" . "$row_rstest[Ag]\r\n" . "MO:" . "$row_rstest[Mo]\r\n" . "ZN:" . "$row_rstest[Zn]\r\n" . "P:" . "$row_rstest[P]\r\n" . "CA:" . "$row_rstest[Ca]\r\n" . "BA:" . "$row_rstest[Ba]\r\n" . "MG:" . "$row_rstest[Mg]\r\n" . "SI:" . "$row_rstest[Si]\r\n" . "NA:" . "$row_rstest[Na]\r\n" . "B:" . "$row_rstest\r\n" . "V:" . "$row_rstest[V]\r\n" . "PQ:" . "$row_rstest[PQ]\r\n" . "WATERKF:" . "$row_rstest[Water_KF]\r\n";
                } while ($row_rstest = mysql_fetch_assoc($rstest));
                mysql_free_result($rstest);
                ?>

                Works like a dream...

                Thanks all

                  Write a Reply...