wispas Posted January 12, 2010 Share Posted January 12, 2010 I have a simple form with a text area. i add 2 line breaks to start a new paragraph and insert it into the mysql database. so i retrieve the post data: $city_desc = $_POST['city_desc'] ; and it will stick all of the data together when i output with php.. i want it to retain the 2 line breaks so they are like new paragraphs... any ideas? Link to comment https://forums.phpfreaks.com/topic/188222-preserving-line-breaks-text-area-insertation-to-mysql/ Share on other sites More sharing options...
Zane Posted January 12, 2010 Share Posted January 12, 2010 look at nl2br() Link to comment https://forums.phpfreaks.com/topic/188222-preserving-line-breaks-text-area-insertation-to-mysql/#findComment-993711 Share on other sites More sharing options...
fooDigi Posted January 12, 2010 Share Posted January 12, 2010 odd are the line breaks are being stored, but when parsed as html they are run together. try echo'ing your content with nl2br() Link to comment https://forums.phpfreaks.com/topic/188222-preserving-line-breaks-text-area-insertation-to-mysql/#findComment-993712 Share on other sites More sharing options...
greatstar00 Posted January 12, 2010 Share Posted January 12, 2010 if u dont want to use nl2br u can use <pre>textarea data</pre> Link to comment https://forums.phpfreaks.com/topic/188222-preserving-line-breaks-text-area-insertation-to-mysql/#findComment-993717 Share on other sites More sharing options...
wildteen88 Posted January 12, 2010 Share Posted January 12, 2010 odd are the line breaks are being stored, but when parsed as html they are run together. try echo'ing your content with nl2br() This is because web browsers ignore white space characters, such as new lines. In order for a new line to appear in a web browser you need use the <br /> tag. nl2br() converts new lines into <br /> tags. Link to comment https://forums.phpfreaks.com/topic/188222-preserving-line-breaks-text-area-insertation-to-mysql/#findComment-993721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.