display line breaks from MySQL text field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

display line breaks from MySQL text field

Post by inosent1 »

i am not sure how to phrase the topic, but when i store the data from my php form it looks like this
first line

third line

fifth line
when i look at the mysql data field it looks the same way

but when i pull it from the DB to view the result is:
first line third line fifth line
how do i get it to show with the line breaks?
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: display line breaks from MySQL text field

Post by twinedev »

well where are you displaying it that it is showing all one line? As output in a browser?

If so, you either need to wrap it with styling retain spacing (ie, <pre>) or pass it through nl2br()

-Greg
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Re: display line breaks from MySQL text field

Post by inosent1 »

thank you for your reply!

it works

Code: Select all

<td  valign=top><span class="style2"><?php echo nl2br("$notesa"); ?>
Post Reply