开发者

Keep text formatting in SQL

开发者 https://www.devze.com 2023-01-04 11:20 出处:网络
I have a text area that inserts its content into a SQL table. Is there a way to keep the formatting of the text and then use it i开发者_如何学JAVAn HTML?I\'ll assume you\'re talking about preserving l

I have a text area that inserts its content into a SQL table. Is there a way to keep the formatting of the text and then use it i开发者_如何学JAVAn HTML?


I'll assume you're talking about preserving line breaks.

Either:

Output the text inside a <pre> tag

or

Convert newlines to <br /> tags before insertion to the DB. (E.g. nl2br in PHP).


If you mean keep the Enters then replace the char 10 and char 13 with <br/>

When using SQL (note the enters)

select replace(' 
test
test','
','<br/>')

This results in <br/>test<br/>test


Text is text is text. Insert the text into the table including its markup and it will come out that way as well.

...or am I misunderstanding your question?

0

精彩评论

暂无评论...
验证码 换一张
取 消