newbeee Posted January 22, 2009 Share Posted January 22, 2009 the news field in my database is a text type what i wish to know is how to have text that has line breaks within the text still show with these line breaks when i grab the data again to show it in the page it is ment for. at the moment all the text seems to just continue on one long line and breaks up when the end of the page is reached. edit file <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <? include("config.php"); if($_POST['submit'] == "submit") { $update = mysql_query("UPDATE `news` SET `news` = '" . $_POST['news'] . "'"); } else { $news = mysql_query("SELECT * FROM `news`"); ?> <textarea name="news" cols="80" rows="10"><?=@mysql_result($news, 0, 'news');?></textarea><br> <input name="submit" type="submit" value="submit"> <? } ?> </body> </html> display page <?=@mysql_result($mpsurgeries_news, 0, "mpsurgeries_news");?> Quote Link to comment https://forums.phpfreaks.com/topic/141895-newlines-not-showing-up-when-info-previously-stored-in-db-is-displayed-on-page/ Share on other sites More sharing options...
Mchl Posted January 22, 2009 Share Posted January 22, 2009 Use nl2br when displaying text. Quote Link to comment https://forums.phpfreaks.com/topic/141895-newlines-not-showing-up-when-info-previously-stored-in-db-is-displayed-on-page/#findComment-743050 Share on other sites More sharing options...
salami1_1 Posted January 22, 2009 Share Posted January 22, 2009 and if you don't want the newlines at all use: $yourstring = str_replace("\n", "", $yourstring); B.r. Quote Link to comment https://forums.phpfreaks.com/topic/141895-newlines-not-showing-up-when-info-previously-stored-in-db-is-displayed-on-page/#findComment-743140 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.