Jump to content
xisto Community
Sign in to follow this  
masugidsk8r

Problems With Data Formatting

Recommended Posts

I have a MySQL database which stores articles. A sample article would look like this:

This is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.

That's how it's displayed in the MySQL Database. Currently the data type is "TEXT". But when I load it on a php page to display that same article, it would show the same data but wouldn't have separate paragraphs. How would I be able to display the text in separate paragraphs?

Share this post


Link to post
Share on other sites

On the php.net site, search for htmlentities() and nl2br(), the functions which converts potentially dangerous and damaging code tags from their 'regular' form into a format which is not dangerous nor damaging and there are others I am sure . Finding these functions and following the links in those descripptions will lead you to other functions to use, too.

The original data contains internal characters for tabs, carriage returns, new lines, etc, so the data needs to be altered from its source, to some thing safe. Use functions like these to do the cleansing. Then, when you remove the data from the database and proceed to print it or display it, the product looks the same as when it went in.

 

http://php.net/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.