Jump to content

Recommended Posts

No, I'm not talking spacing between each row.

 

Like say you have a textarea, and you enter:

"blah blah blah

blah

blah blah

blah blah blah blah"

 

It goes into the MySQL table like this:

"blah blah blah blah blah blah blah blah blah blah"

 

Is there any way to change that?

Link to comment
https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268660
Share on other sites

How are you inserting it into your database table? Post the relevant parts of your code here.

 

If you enter

line1
line2
another line
b
l
a
h

It should go into the database as you have typed it.

 

However when you get the data back out of the database and display it in the browser you may find it displays as this:

line1line2another lineblah

This is nothing to do with PHP or MySQL but the browser itself. Web browsers ignore most whitespace characters (\n, \r, etc). In order for the browser to display your textareas you have entered it in the textarea you will need to use the html equivalent, eg <br /> for newlines.

Link to comment
https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268756
Share on other sites

No no no, you're not listening.

 

It goes into the table as a one-line string, it doesn't have breaks in it.

 

I think you are the one not listening.

 

Anytime you enter data into a DB from a textarea it has \n characters or new line characters. www.php.net/nl2br converts the \n to < br />  so it is visible by the webbrowser.

 

I bet if you viewed the source of the data currently printed it would look like it did when you entered it into the DB.

 

Give it a try and see what happens.

Link to comment
https://forums.phpfreaks.com/topic/54272-format-mysql-info/#findComment-268764
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.