dmc2211 Posted October 18, 2006 Share Posted October 18, 2006 Hi, I have set up a CMS to add properties. There is a text area box to submit specifictions about the property. When I add the specifications to the text area it looks like this:[b]Entrance Porch: :-Wooden floor.Entrance Hall:- Wooden floor.Lounge: 17' 5'' x 11' 11'' 5.31m x 3.63m. Wooden floor. Pine fireplace with cast iron inset. TV Point. Recess lighting.[/b]The problem is when it submits to the database it eliminates the returns and when it displays from the database it looks like a paragraph e.g. [b]Entrance Porch:-Wooden floor.Entrance Hall:- Wooden floor.Lounge: 17' 5'' x 11' 11'' 5.31m x 3.63m. Wooden floor. Pine fireplace with cast iron inset. TV Point. Recess lighting.[/b]If I add "break tags"to the text before submitting to the database this displays correctly but I dont want to add these tags everytime I submit data to the database.I was looking at str_replace(). Basically I would like to replace anywhere in the text that has ":-" with "break tags"Any tips? Quote Link to comment Share on other sites More sharing options...
printf Posted October 18, 2006 Share Posted October 18, 2006 The returns are not removed you just don't see them, just use [b]nl2br()[/b], when you show the result coming out of the database!me! Quote Link to comment Share on other sites More sharing options...
dmc2211 Posted October 18, 2006 Author Share Posted October 18, 2006 [quote author=printf link=topic=111905.msg453804#msg453804 date=1161182093]just use [b]nl2br()[/b], when you show the result coming out of the database![/quote]Where should I display this piece of code? I have a recordset and this pulls the description from the database. Before the text was submitted to the database it had line breaks. When the recordset pulls this from the database it loses these line breaks and looks like a paragraph. I'm sorry all this is very new to meThanks Quote Link to comment Share on other sites More sharing options...
printf Posted October 18, 2006 Share Posted October 18, 2006 \r or \n are never really seen in a html formatted page unless you use < pre >, but they are not lost either!So when you run your query, you add the function nl2br(); on the return row of data that has the \r?\n in it's content[code]$query = mysql_query ( "SELECT my_column FROM my_table WHERE this = that" );while ( $row = mysql_fetch_assoc ( $query ) ){ $text = nl2br ( $row['my_column'] ); // or if you don't want resign the $row variable $row['my_column'] = nl2br ( $row['my_column'] );}[/code]me! Quote Link to comment Share on other sites More sharing options...
dmc2211 Posted October 18, 2006 Author Share Posted October 18, 2006 Got it thanks for all your help!! Quote Link to comment 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.