imarockstar Posted June 18, 2007 Share Posted June 18, 2007 im trying to figure out how to format text in a database ... If I have a TEXT AREA in a form .. and an user inputs say like 5 paragraphs ... how can I have it to where mysql will display that as 5 paragraphs and not just i chunk of text when i display it at a later date ? b Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/ Share on other sites More sharing options...
liam1412 Posted June 18, 2007 Share Posted June 18, 2007 You can do this using the nl2br() function basically $text = nl2br($text); That will format it for you Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/#findComment-276923 Share on other sites More sharing options...
per1os Posted June 18, 2007 Share Posted June 18, 2007 www.php.net/nl2br That would be what you are looking for. Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/#findComment-276924 Share on other sites More sharing options...
liam1412 Posted June 18, 2007 Share Posted June 18, 2007 You do this when collecting from the db and not when inputting to save space. Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/#findComment-276925 Share on other sites More sharing options...
akitchin Posted June 18, 2007 Share Posted June 18, 2007 MySQL will store the text with linebreaks as either \r\n or \n. in order to properly format it for display in HTML, you'll need to convert those "\n" characters to "<br />" tags, as HTML ignores whitespace. PHP has a function to do just that: nl2br() give it a whirl. EDIT: beaten to the punch, but i'm putting this here anyway. Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/#findComment-276926 Share on other sites More sharing options...
imarockstar Posted June 18, 2007 Author Share Posted June 18, 2007 awsome guys I will give this a try !!! thanks ... b Quote Link to comment https://forums.phpfreaks.com/topic/56070-long-text-help/#findComment-276960 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.