Save text formatting in SQL

I have a text area that inserts its contents into an SQL table. Is there a way to keep the formatting of the text and then use it in HTML?

+3
source share
3 answers

If you want Enters to replace char 10 and char 13 with <br />

When using SQL (pay attention to input)

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

The result is <br/>test<br/>test

+2
source

I assume that you are talking about keeping line breaks.

Or:

Print text inside the <pre> tag

or

Converting line feed strings to tags before inserting into the database. (For example, nl2br in PHP).

+4
source

- . , , .

... ?

+1
source

Source: https://habr.com/ru/post/1750670/


All Articles