Jump to content

MySQL + PHP + INSERT


iGetty

Recommended Posts

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?

 

78ojO.png

 

 

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.