Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store text in database with line breaks or paragraph

In my application I have Terms for Apps. Before I used to put this in front-end with HTML .

But now I need to put this text in database in a column called AppTerms inside table called App.

I referred to this link in stackoverflow and followed like this :

UPDATE [AppsDatabase].[dbo].[App]
SET AppTerms = 'This App has no minimum term.' + CHAR(13) +
'This App is built and is supported through the standard way of using the company online support.' + CHAR(13) +
'Incorrectly formatted data will not be formatted but may be charged for.'
 WHERE AppID = 8
 GO

But I am not getting line breaks here. And also can someone tell me how can i put bullet points in each line?

like image 377
Ajay Avatar asked Sep 05 '25 17:09

Ajay


2 Answers

If you are showing HTML you need to store </br> instead of CHAR(13).

Displaying this text in HTML will yield the correct display. In addition you can wrap a paragraph in <p>...</p>.

For bullet lists look at http://www2.gol.com/users/billp/articlehtml/bullet.html.

This is under the assumption that you take the text out and display in HTML.

like image 166
KMB Avatar answered Sep 08 '25 12:09

KMB


It might be too late, yet, I had the same problem... The solution I came up with is to store paragraphs(or lists... or whatever) in a separate child table and handle the formatting at the server programming language level.

like image 23
user3134422 Avatar answered Sep 08 '25 12:09

user3134422