We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,434 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Replace line breaks with <br />?

I have some text in a mysql table, stored as text and taken from an html <textarea>.

For example of some text.
Hi this
is Glens
webpage

When I display this on my web page it comes out as

Hi this is Gles webpage.

How do I get it to display with the newlines?

Here is the code.

while($info = mysql_fetch_array( $data )) { 
                          $date = $info["date"];
                          $date = strftime("%b %d, 20%y", strtotime($date));  

                          echo "<span class='span2'>";
                          echo "<p>";
                          echo $info['title'];
                          echo "......".$date;
                          echo $info['content'];
                          echo "</p>";
                          echo "</span>";
                          echo "<br />";

Thanks for looking.................

2
Contributors
2
Replies
15 Minutes
Discussion Span
6 Months Ago
Last Updated
3
Views
Question
Answered
GlenRogers
Posting Whiz in Training
261 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

echo nl2br($info['content']);

urtrivedi
Posting Virtuoso
1,724 posts since Dec 2008
Reputation Points: 299
Solved Threads: 366
Skill Endorsements: 24

Ahhhhhhhhhhhhh thats it!

Many thanks.................

GlenRogers
Posting Whiz in Training
261 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 6 Months Ago by urtrivedi

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0603 seconds using 2.67MB