Reputation: 5492
I am trying to fetch data from database and I need it to be displayed in the same format as stored in the database. Please note that the data stored in the database is just by using text-area, i.e. without using ck-editor.
For example, the data stored in database is:
Hello,
How are you jack?
Thanking you.
But the problem is when I try to display it, it appears as follows:
Hello, How are you jack? Thanking you.
I want to display it in the same format as stored in database. I want to do it without using any kind of editor.
Upvotes: 1
Views: 1674
Reputation: 15374
In HTML newlines don't break lines. You can output the string wrapped in a "pre" tag, or take the text and replace newlines with "br" (break) tags.
You make no mention of which programming language you're using. With PHP, you can pass your string from the database through the nl2br() function to replace newlines with HTML breaks.
Upvotes: 1
Reputation: 4275
This is related to php. There is no problem in php to print it as it is use <pre>
tag in html.Your code should look like this
$data= "Hello,
How are you jack?
Thanking you.";
echo '<pre>$data</pre>';
Hope this helps you
Upvotes: 0