[ciapug] Formatting with line breaks...

David Champion ciapug@cialug.org
Mon, 15 Dec 2003 11:21:56 -0600


When you write the string to the table. do the chr(13) . chr(10) thing.

When you display it, if it's in an HTML page or HTML email, you need to 
use the php nl2br function to replace the newline (what you inserted 
with the chr's) with a <br> tag. I do this exact thing all the time, it 
works just fine.

When you display it in phpMyAdmin, or as a query from the mysql console, 
it should keep the line breaks.

-dc

Chris Hettinger wrote:

>Background, I have a application that collect information in a mysql db,
>does some processing, and based on the outcome I either build a
>formatted email and send it, or do a series of inserts into our mssql
>server and in this case I have to insert a formatted notes entry.
> 
>I have to write this information two different ways, I will do one or
>the other:
> 
>1. Formatted Email Message
>2. Into a long text DB field, that will then be displayed in a internal
>application
> 
> 
>Tim: No I had not used the <pre></pre> tags
> 
>-ch
>
>-----Original Message-----
>From: ciapug-admin@cialug.org [mailto:ciapug-admin@cialug.org]On Behalf
>Of Jerry Weida
>Sent: Monday, December 15, 2003 8:38 AM
>To: ciapug@cialug.org
>Subject: Re: [ciapug] Formatting with line breaks...
>
>
>Where are you writing this output to?  A file?  A browser?
>
>Chris Hettinger wrote:
>
>
>Hmm, this didn't seem to work either.
>
>
>
>        $note = "*** Generate from Web Form Submission ***" . chr(13) .
>chr(10)
>
>              . "testing note formatting.";
>
>
>
>Still writes a single line.  hrmmm... 
>
>
>
>*still trying*
>
>-----Original Message-----
>
>From: David Champion [ mailto:dave@visionary.com]
>
>Sent: Friday, December 12, 2003 4:56 PM
>
>To:  ciapug@cialug.org
>
>Subject: Re: [ciapug] Formatting with line breaks...
>
>
>
>
>
>You're thinking of a different issue, Jerry. That's addressed with the 
>
>nl2br() function.
>
>
>
>He needs to actually insert :
>
>$x = "text " . chr(13) . chr(10);
>
>
>
>I don't recall that there's a constant for CRLF, like VB's vbCRLF... but
>
>
>you could put on in your code, i.e.
>
>
>
>$_CRLF = chr(13) . chr(10);
>
>
>
>-dc
>
>
>
>Jerry Weida wrote:
>
>
>
>  
>
>Are you checking the source?  Text-style line breaks won't display in 
>
>a browser, but they will show up in the source.
>
>
>
>Chris Hettinger wrote:
>
>
>
>    
>
>I am trying to insert into a db field a note entry which will contain 
>
>the details of a web form, but I have to build that long note entry 
>
>first, and do some light formatting like line breaks...
>
>
>
>       $note = "Generate from Web Form Submission \r\n"
>
>             . "testing note formatting. \r\n";
>
>
>
>How ever this isn't working as I would have suspected. For testing it 
>
>as I build it I am just echoing it out to the browser with <?= $note; 
>
>?> ... It displays but is not including the line breaks.
>  
>