steve wrote:
"Jonathan" wrote: > I want to save textarea contents to a mysql database with the
> paragraph breaks intact without having to type paragraph or break
tags > in HTML. How can I do that. So far, although it occurs naturally
when > I save the contents to a file, it doesn’t break up the
> paragraphs
> properly when I save it to my database.
>
> Thanks!
>
> Jonathan
> http://thewebdevelopment.com
Jonathan, textarea uses cr\lf to break lines. That is how it would
be saved into db, if your program does no extra translations. Upon
display on html page, cr\lf could then be replaced by html break
tags.
I don’t know of paragraph breaks. I believe that is simply double
cr\lf’s.
I would like to suggest a small correction:
A 'paragraph break' is actually CR/LF. A textarea will break lines using
wordwrap. (To some people a paragraph break is known as a 'hard break':
its hard-coded, whereas a wordwrap is a 'soft break': software
calculates it.) A wordwrap doesn't actually use any symbol wthin the
stored text, since the position of the line breaks will alter depending
on the media in which the text is displayed.
HTML also uses wordwrap, but it ignores CR/LF. In its place you can use
either a <BR> for linebreak or <p> for paragraphs. If you have a block
of text which uses CR/LFs that you wish to display in HTML, then you'll
need to substitute <br> for each of the CR/LFs. (in PHP there is a
function nl2br() that does this.)
History: CR/LF goes back to the days of early printers where the codes
replicated the actions of a typewriter. CR (carriage return) returned
the carriage to the start of a new line. LF (line feed) advanced to the
next line. The lever at the left end of a typewriter combined moving
the carriage and advancing the line. Typists used to apply a CR/LF at
the end of every line and an extra CR/LF between paragraphs. As electric
typewriters came into use they would automatically apply the CR/LF when
the end of the line was reached.
Now with wordprocessing and wordwrap, the CR/LF at the end of each line
is no longer neccessary.
Any corrections/improvements to this explanation would be greatfully
received.
Mike