Rickstar
Rickstar

Reputation: 6189

How to display php echo the same as you see in mysql

I currently have a MySQL table called _post and i have a column called message (TEXT)

When i insert a row into the table the text looks like this in phpmyadmin

This is Correct How I Want It To Display

How much do you use your computer?
You might be spending to much time.....

But when i echo it out of the database it looks like this

    How much do you use your computer? You might be spending to much time.....

Thank You

Upvotes: 0

Views: 55

Answers (4)

dxit
dxit

Reputation: 658

You can use the nl2br() function to display your data.

Example:

echo nl2br($mysql_text);

Regards

Upvotes: 0

ChrisR
ChrisR

Reputation: 14447

Since your output is processed as HTML you won't see the newlines that are present in your database. In HTML you need a <br>-tag to display a newline in your browser.

PHP has a function that converts any newline to a <br>-tag for you: nl2br()

Upvotes: 0

Abdullah Jibaly
Abdullah Jibaly

Reputation: 54790

Looks like you need to convert \n (newlines) to <br>s.

Upvotes: 0

Sinan
Sinan

Reputation: 5980

You should use something like nl2br() function.

Upvotes: 2

Related Questions