jcstanley Posted October 16, 2006 Share Posted October 16, 2006 HiI am currently copying data into a database from an existing page on my site.When the text is entered into a text area on a form it is paragraphed. But when viewed on the page wich retrieves the data from the database it is just one continuous chunk of text.Is there any way of keeping the paragraphs etc? (A similar format to entering a post on this site would be ideal)Thanks Link to comment https://forums.phpfreaks.com/topic/24121-keeping-paragraphs-etc/ Share on other sites More sharing options...
kenrbnsn Posted October 16, 2006 Share Posted October 16, 2006 What are you using to view the data in the database?When displaying the data back to a browser, the browser does not interpret the newline character. To be able to show the text correctly use the [url=http://www.php.net/nl2br]nl2br()[/url] function.Example:[code]<?php$text = "this text has \nnewline\n characters in it";echo nl2br($text);?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/24121-keeping-paragraphs-etc/#findComment-109643 Share on other sites More sharing options...
jcstanley Posted October 16, 2006 Author Share Posted October 16, 2006 Cheers KenThat works perfectly! Link to comment https://forums.phpfreaks.com/topic/24121-keeping-paragraphs-etc/#findComment-109651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.