Jump to content

Archived

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

jcstanley

Keeping paragraphs etc.

Recommended Posts

Hi
I am currently copying data into a database from an existing page on my site.

When the text is entered into a text area on a form it is paragraphed.  But when viewed on the page wich retrieves the data from the database it is just one continuous chunk of text.

Is there any way of keeping the paragraphs etc? (A similar format to entering a post on this site would be ideal)

Thanks

Share this post


Link to post
Share on other sites
What are you using to view the data in the database?

When displaying the data back to a browser, the browser does not interpret the newline character. To be able to show the text correctly use the [url=http://www.php.net/nl2br]nl2br()[/url] function.

Example:
[code]<?php
$text =  "this text has \nnewline\n characters in it";
echo nl2br($text);
?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

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.