elmas156 Posted August 31, 2010 Share Posted August 31, 2010 Hello everyone. I'm creating a website that has a sort of messaging system built in and I'm trying to get the information pulled out of the database to display exactly as it was typed. For example, if someone types this message: "This is the first line. This is the second line. And this is two lines below the second line." (By the way, when I view this message using phpMyAdmin, the message is displayed in the above format.) I would like to have the message displayed the same way when it is queried from the database. As of now, this is what I'm seeing instead: "This is the first line. This is the second line. And this is two lines below the second line." How can I achieve this? I would post the code that I'm using, but it's just a basic mysql query to get a variable "$message" then I'm just using echo "$message"; to put it on the page. Any help to point me in the right direction would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/212216-multiple-lines-displayed-from-mysql-string/ Share on other sites More sharing options...
wildteen88 Posted August 31, 2010 Share Posted August 31, 2010 When you output the text from the database use nl2br Quote Link to comment https://forums.phpfreaks.com/topic/212216-multiple-lines-displayed-from-mysql-string/#findComment-1105802 Share on other sites More sharing options...
elmas156 Posted August 31, 2010 Author Share Posted August 31, 2010 Wow, that was easy... I guess it helps to know where to look and the terminology to search for. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/212216-multiple-lines-displayed-from-mysql-string/#findComment-1105847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.