Page 1 of 1

Can not display new line character

Posted: Mon Apr 16, 2007 2:21 pm
by hoangvu.che
After retrieving data from MySQL, I display all data on my page (in a <td> tag).
However, the new line character is automatically omitted.

I have checked by filling the data in a textfield, the new line character exists normally.

Please help me how to display the data correctly.

thanks.

Posted: Mon Apr 16, 2007 2:38 pm
by Weirdan

Code: Select all

echo '<td>' . nl2br($data) . '</td>';
There are linebreaks (you can see them when viewing generated html via 'View source'), but browsers just ignore them.

Posted: Tue Apr 17, 2007 11:54 am
by hoangvu.che
thanks Weirdan.

it can be solved with nl2br() function.