iGetty Posted February 24, 2014 Share Posted February 24, 2014 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 Link to comment https://forums.phpfreaks.com/topic/286464-mysql-php-insert/ Share on other sites More sharing options...
Ch0cu3r Posted February 24, 2014 Share Posted February 24, 2014 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 Link to comment https://forums.phpfreaks.com/topic/286464-mysql-php-insert/#findComment-1470394 Share on other sites More sharing options...
iGetty Posted February 24, 2014 Author Share Posted February 24, 2014 That's great, thank you! Link to comment https://forums.phpfreaks.com/topic/286464-mysql-php-insert/#findComment-1470516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.