Jump to content

Preserving line breaks (Text Area insertation to MySQL)


wispas

Recommended Posts

I have a simple form with a text area.

i add 2 line breaks to start a new paragraph and insert it into the mysql database.

 

so i retrieve the post data:

 

$city_desc = $_POST['city_desc'] ;

 

and it will stick all of the data together when i output with php.. i want it to retain the 2 line breaks so they are like new paragraphs... any ideas?

odd are the line breaks are being stored, but when parsed as html they are run together. try echo'ing your content with nl2br()

This is because web browsers ignore white space characters, such as new lines. In order for a new line to appear in a web browser you need use the <br /> tag. nl2br() converts new lines into <br /> tags.

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.