Mundo Posted October 19, 2009 Share Posted October 19, 2009 I have data in my MySQL such as: Blah blah Blah blah etc but when i echo it out, there is no formatting left it comes out as: Blah blah Blah blah etc is there an easy way to stop this? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted October 19, 2009 Share Posted October 19, 2009 What do you mean? If you output things, it'll be output verbatim. If you output things to a browser with an text/html MIME type it will ignore consecutive whitespace, however (check the source). You can use nl2br to convert line breaks (ASCII code 10) to (X)HTML line breaks. You can also use CSS rules to preserve whitespace. Quote Link to comment Share on other sites More sharing options...
Mundo Posted October 19, 2009 Author Share Posted October 19, 2009 Well basically the data in the database has linebreaks but when i output it the linebreaks disappear... I want them back without having to insert HTML into the database. As you can see in my screenshot... I want my linebreaks to back to make it more readable. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Mundo Posted October 19, 2009 Author Share Posted October 19, 2009 (ignore the narrow layout etc, it's designed for iPhone) Quote Link to comment Share on other sites More sharing options...
Mundo Posted October 20, 2009 Author Share Posted October 20, 2009 There must be a simple way to do this? Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 20, 2009 Share Posted October 20, 2009 Can i see the format you already done please. you been advised ill hold your hand? Quote Link to comment Share on other sites More sharing options...
Mundo Posted October 20, 2009 Author Share Posted October 20, 2009 $query = mysql_query("SELECT * FROM recipes WHERE id = '$_GET[recipeid]'"); $row = mysql_fetch_assoc($query); $method = $row['method']; $method = str_replace('<br />', "\n", $method); I've currently got this, but this won't add my line breaks back in either. What do you mean, see the format i've already done? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 You can use nl2br to convert line breaks (ASCII code 10) to (X)HTML line breaks. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 20, 2009 Share Posted October 20, 2009 Dan was trying to teach you, new line to brake, Look at the examples in the below link your understand. http://uk2.php.net/nl2br Siide note. when you enter information in the database, as a brake <br> it's referenced as a special character, to tell the database it a brake <br>, you Paul them brakes out using nl2br() function. database example with $row $text=nltbr($row['text']); echo $text walla. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 ... what? That post doesn't make sense. Quote Link to comment Share on other sites More sharing options...
Mundo Posted October 20, 2009 Author Share Posted October 20, 2009 Ah sorry, was as simple as nl2br($row['method']); Sorry I must have misread your post before. Thanks for the help! Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 20, 2009 Share Posted October 20, 2009 dan i tried again lol. Dan was trying to teach you, new line to brake, Look at the examples in the below link your understand. http://uk2.php.net/nl2br Side note. when you enter information in the database, as a brake <br> it's referenced as a special character, to tell the database it a brake <br>, you Paul them brakes out using nl2br() function. database example with $row $text=nltbr($row['text']); echo $text walla. Quote Link to comment 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.