mr_badger Posted June 14, 2007 Share Posted June 14, 2007 I have text ina database that I can view in a webpage but there is no formatting. Is there some way of creating page breaks or paragraphs from text in a database? Quote Link to comment https://forums.phpfreaks.com/topic/55598-database-text/ Share on other sites More sharing options...
chocopi Posted June 14, 2007 Share Posted June 14, 2007 well as long as you use textarea you can use nl2br() to insert it into the database and then when you retrieve it, it should remain the same EG $text = nl2br($text); Hope it helps ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/55598-database-text/#findComment-274723 Share on other sites More sharing options...
wildteen88 Posted June 14, 2007 Share Posted June 14, 2007 well as long as you use textarea you can use nl2br() to insert it into the database and then when you retrieve it, it should remain the same EG $text = nl2br($text); Hope it helps ~ Chocopi Don't use nl2br when you insert text into the database. Only use nl2br when you go to display the text to the page. The database will preserve whitespace characters (newlines). The browser ignores whitespace characters that is why when you print text will newlines in it shows it as just one line. When you use nl2br it converts the whitespace newline chars into a HTML line break (<br />). Quote Link to comment https://forums.phpfreaks.com/topic/55598-database-text/#findComment-274774 Share on other sites More sharing options...
chocopi Posted June 14, 2007 Share Posted June 14, 2007 Thanks for correcting my mistake, god knows why i put that Quote Link to comment https://forums.phpfreaks.com/topic/55598-database-text/#findComment-274777 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.