ricmetal Posted March 29, 2009 Share Posted March 29, 2009 so, the text inside a textarea keeps it's linebreaks from appearing in the db, and in the textarea once brought into it, from the db. the div however, contentEditable, shows its <br>'s and they are stored in the db, and appear in the html when brought in from the db mind you that they are not rendered into the html, they appear as text, but this doesnt happen with the textarea, which keeps its <br>'s hidden how do i make the div imitate this hide effect that the textarea does to hide the <br> from showing, but maintaining line breaks? i red somethign about wrapping the div with pre but i was wondering if there's a fixed solution (that is comonly used) to do what im after. Quote Link to comment https://forums.phpfreaks.com/topic/151608-solved-textarea-and-div/ Share on other sites More sharing options...
fabrydesign Posted March 29, 2009 Share Posted March 29, 2009 Are you using htmlspecialchars or a similar function before storing it? If I'm understanding you correctly, what you'll want to do is store the raw textarea value in the database, then use nl2br() on it on the page to show the new lines (as entered in the textarea). Quote Link to comment https://forums.phpfreaks.com/topic/151608-solved-textarea-and-div/#findComment-796359 Share on other sites More sharing options...
ricmetal Posted March 30, 2009 Author Share Posted March 30, 2009 just using mysql_real_escape_string before storing fabry the text from the textarea is displayed correctly. it goes raw to the db and comes out with the line breaks (i use nl2br btw), appearing correctly in the textarea, and html (either way i choose to see it) what i need is for the div to act the same way i am using htmlspecialchars when bringing the data from the db Quote Link to comment https://forums.phpfreaks.com/topic/151608-solved-textarea-and-div/#findComment-796745 Share on other sites More sharing options...
wildteen88 Posted March 30, 2009 Share Posted March 30, 2009 Make sure you call htmlspecialchars before you call nl2br. If you call nl2br first followed by htmlspecialchars the break tags will be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/151608-solved-textarea-and-div/#findComment-797005 Share on other sites More sharing options...
ricmetal Posted March 30, 2009 Author Share Posted March 30, 2009 yeah, i am calling before and the br was displayed anyway so, idk but anyway its fixed now replaced br with \r Quote Link to comment https://forums.phpfreaks.com/topic/151608-solved-textarea-and-div/#findComment-797083 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.