Question:
Line return in text area with html/php/mysql?
another_man
2008-04-09 10:48:01 UTC
I have a textarea control in my php/mysql based web site and it allow the user to enter text
in
different
lines
as this
example
then I write info in mysql database, but when I read and show information in a TD on another page, the line return are lost and all the text is on a single line.

Can you help me with this ?
Do you need more detail to help me?

Thanks a lot !
Three answers:
anonymous
2008-04-09 10:54:25 UTC
Run it through nl2br() to convert the new lines into HTML line breaks.



gnomie_jones
2008-04-09 19:21:59 UTC
yup, these guys are correct.



if you try to dump the data back into the textarea at a later time it'll display the
as text tho, use this to get around:



anonymous
2008-04-09 17:54:26 UTC
use nl2br();



like this -



$formated_text = nl2br($_POST['text']);


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...