smartin1017 Posted November 29, 2008 Share Posted November 29, 2008 This is probably a real simple one for you guys, but I have a text area that saves a nio, the probalem is most people have more then a paragraph for there bio, how do I get the database to save the breaks and spaces between paragraphs and indents? Quote Link to comment https://forums.phpfreaks.com/topic/134769-getting-test-to-save-breaks-in-database/ Share on other sites More sharing options...
MatthewJ Posted November 29, 2008 Share Posted November 29, 2008 The line breaks should be saved in the database... When you output the content, use nl2br(). That will convert the \n to break tags in the output. Have never tried with indent Quote Link to comment https://forums.phpfreaks.com/topic/134769-getting-test-to-save-breaks-in-database/#findComment-701770 Share on other sites More sharing options...
flyhoney Posted November 29, 2008 Share Posted November 29, 2008 If you need to retain indentions as well as nl2br() I suppose you could use CSS: p { white-space: pre; } Quote Link to comment https://forums.phpfreaks.com/topic/134769-getting-test-to-save-breaks-in-database/#findComment-701804 Share on other sites More sharing options...
smartin1017 Posted November 30, 2008 Author Share Posted November 30, 2008 I looked into that function but for soeone coming to the site and filling in info they are not going to know to put in /n. Think of a social network, you fill in all these different textareas and they always show the paragraphs with the breaks. How do they do this, I am thinking they might use javascript with php. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/134769-getting-test-to-save-breaks-in-database/#findComment-702043 Share on other sites More sharing options...
flyhoney Posted November 30, 2008 Share Posted November 30, 2008 I looked into that function but for someone coming to the site and filling in info they are not going to know to put in /n. Think of a social network, you fill in all these different textareas and they always show the paragraphs with the breaks. How do they do this, I am thinking they might use javascript with php. Any ideas? They dont put in "\n". Whenever you press the Enter key on your keyboard, that is where the "\n" comes from. So people filling out a bio would just hit Enter, which would take them to the next line, like this and the nl2br() function will make sure that, when you display the text, the \n's are preserved. Does that make sense? \n is a whitespace character, that means that nobody sees it. Spacebar is represented by \s, and tabs are represented by \t, they are also whitespace characters. Quote Link to comment https://forums.phpfreaks.com/topic/134769-getting-test-to-save-breaks-in-database/#findComment-702051 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.