DiscoTrio Posted December 6, 2009 Share Posted December 6, 2009 Ok, I have a database with tons of user-submitted data, each somewhere over 200 characters. When I do a normal way of echoing a row from it all formatting is gone. (I dont mean like bold and stuff, there is no coding in text) but where the user hits enter is gone. For example: User enters this: Hi, Im Bob This is my text entry. Database knows its this: Hi, Im Bob This is my text entry. Comes out on php page as this: Hi, Im BobThis is my text entry. Here is the code that echo's the data, I just wanna know how to keep that formatting there... $result = mysql_query("SELECT * FROM snews WHERE id = '0' LIMIT 0,1"); while($row = mysql_fetch_array($result)) {$cnumber = $row['id2']; $pointsgetter = $row['username']; $article = $row['id2']; echo $row['username'] . " wrote:<br>" . $row['title'] . "<br><br>" . $row['content'] . "<br><br>About: " . $row['game']; echo "<br><a href='mod1.php?action=approve&cnumber=$cnumber'>[Approve]</a>"; echo " <a href='mod1.php?action=delnews&cnumber=$article'>[Delete]</a>"; } Link to comment https://forums.phpfreaks.com/topic/184201-how-do-i-keep-simple-text-formatting-when-echod-from-database/ Share on other sites More sharing options...
greatstar00 Posted December 6, 2009 Share Posted December 6, 2009 add nl2br this function is called new line to break br = <br /> because html sucks, they dont show newline character, even u have in code\ they only show <br /> as new line Link to comment https://forums.phpfreaks.com/topic/184201-how-do-i-keep-simple-text-formatting-when-echod-from-database/#findComment-972480 Share on other sites More sharing options...
DiscoTrio Posted December 6, 2009 Author Share Posted December 6, 2009 thanx Link to comment https://forums.phpfreaks.com/topic/184201-how-do-i-keep-simple-text-formatting-when-echod-from-database/#findComment-972483 Share on other sites More sharing options...
premiso Posted December 7, 2009 Share Posted December 7, 2009 because html sucks, they dont show newline character, even u have in code\ they only show <br /> as new line Because html sucks? How does that suck, it was designed that way for a very good reason. If it was not then you would get a TON of new lines just from the code being on separate lines itself and if you were to only code new lines when text was involved, well that would be a mess of code and very hard to read. Link to comment https://forums.phpfreaks.com/topic/184201-how-do-i-keep-simple-text-formatting-when-echod-from-database/#findComment-973095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.