newbeee 0 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");?> Link to post Share on other sites
Mchl 0 Posted January 22, 2009 Share Posted January 22, 2009 Use nl2br when displaying text. Link to post Share on other sites
salami1_1 0 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. Link to post Share on other sites
Recommended Posts
Archived
This topic is now archived and is closed to further replies.