joshgarrod Posted July 1, 2011 Share Posted July 1, 2011 Hi all, I am hoping I am able to explain this so here goes: I have a form which inserts data into a table, one field is a textarea. When typing in the textarea you can hit enter to start a new paragraph. But when I pull this info from the database and display it, it appears in one large clump. How do I get PHP to recognise the paragraph? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/ Share on other sites More sharing options...
joe92 Posted July 1, 2011 Share Posted July 1, 2011 Do you mean something like the nl2br function? Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237370 Share on other sites More sharing options...
joshgarrod Posted July 1, 2011 Author Share Posted July 1, 2011 Yes but that appears to need someone to type \n... how do I get it to do it itself? Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237401 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 When the user hits enter, an invisable new line-simbol is inserted. You can store the textarea in your database. When displaying it later, you use the nl2br() function. (nl2br means: "new line to break") Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237405 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Share Posted July 1, 2011 when u print ur string use it like nl2br($string); btw are u using textarea or? Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237406 Share on other sites More sharing options...
joshgarrod Posted July 1, 2011 Author Share Posted July 1, 2011 Thats awesome thanks I will try that. $php_mysql$ - I am using a textarea to pull the data from Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237410 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Share Posted July 1, 2011 cool then this is how i do after i fetch the data form db i store it on a variable like this $text = nl2br($text); and then when i echo $text i get clear results :-) Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237415 Share on other sites More sharing options...
joshgarrod Posted July 1, 2011 Author Share Posted July 1, 2011 cheers for that, exactly what I wanted - PHP really does have an answr for everything! Link to comment https://forums.phpfreaks.com/topic/240892-how-do-i-display-text-from-a-database-and-recognise-the-paragraphing/#findComment-1237418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.