iGetty Posted February 24, 2014 Share Posted February 24, 2014 (edited) Hello there, I am currently struggling with something in regards to auto-line breaking when insterting into the MySQL database. How could I make, so that when there's a line break (Pressing ENTER) for instance, whilst posting this topic, it's automatically breaking the lines for me. How could I make it do that, as if I was creating a blog and I wanted it to be neater? Like there, you see that I've pressed "ENTER" twice, to get to a new line and another? How could I make it so it saves into the SQL database like that? Many regards Edited February 24, 2014 by iGetty Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted February 24, 2014 Solution Share Posted February 24, 2014 (edited) The newlines are infact being saved in the database. The problem is the web browser ignores whitespace characters such as newlines. What you need to do is convert the newlines in to a HTML line break tag <br /> in order for the web browser to render the text on a new line. PHP has a handy function to do this for you called nl2br You'd use the function when outputting the data from the database Edited February 24, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
iGetty Posted February 24, 2014 Author Share Posted February 24, 2014 That's great, thank you! 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.