Reputation: 115
I have an HTML form and when data entered, and submitted values get stored into the database by PHP. When textarea field filled with text for example: Textarea value is:
A
B
C
Then I save this to the database and then display it, it shows up as:
ABC
All the newlines in the text section that added disappear. Is there any way to prevent that?
Upvotes: 0
Views: 59
Reputation: 1005
This is because HTML does not explicitly form a line break with "newline" characters.
You need to use PHP's function nl2br()
to convert all newline characters in your text-area contents to HTML <br>
tags.
Upvotes: 1