In my site, I want user to write their comments. But when they push "enter" in textfield, I want to save this comment as new paragraph to mysql. And I want to fetch this comment from mysql with paragraph.
I googled it and many people suggest "nl2br()", but I couldn't understand how I use it.How can I make it possible? Thank you...
New lines are saved automatically as new lines in mysql, there is no need to do anything special for that.
However, when you output new lines to html, they will show up as spaces (normally...) so when you output to html you have to use nl2br()
so that a <br>
tag gets added with every new line.
<?php echo nl2br($comment); ?>