On Fri, May 15, 2009 at 07:03:49AM -0700, PHPScriptor wrote:

> 
> Hello,
> 
> How do you guys handle this "problem".
> 
> Just a form with a textarea. When I use enters in the textarea it's saved to
> the db like this:
> 
> database:
> "first line
> second line"
> 
> when I edit the value in the form:
> "first line
> second line"
> 
> when I output the value to html:
> "first linesecond line" (unless I use nl2br())
> 
> Is there a way that I could save it to the db that will work for db, output
> and edit without using any other function like nl2br?

If I understand your question, the answer is no. If you have wrap="hard"
as an attribute for your textarea, it will store the data with CR/LF.
But CR/LF don't show up as a line ending when displayed in HTML. You
have to use nl2br() to translate for HTML. It also may be that you need
to do a translation from CR/LF (textarea line ending) to LF (*nix line
ending). The CR/LF *will* show up properly when *editing* in the
textarea field, just not when displayed without a textarea.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to