Jump to content

help getting something from MySQL


monkeymade

Recommended Posts

I have an sql field that is tinytext, the information in it looks like this

line 1
line 2
line 3

But, when I pull it out and echo it, I get

line 1 line 2 line 3

How do I get it to keep the formatting

the information in this field is put in by users, so I have disallowed HTML code otherwise I would just tell people to type in >br> but, with users doing this themselves, its not a good idea
Link to comment
https://forums.phpfreaks.com/topic/29361-help-getting-something-from-mysql/
Share on other sites

You want it displayed in a certain format, so having a table in your display page and using php to call the data from the server in each cell would accomplish that...a php get function where the cell data in the table is...  You would assign a value to each piece of data, write the simple table into the page and use php to call the data into each cell...
[quote author=tracy link=topic=117257.msg478375#msg478375 date=1165239234]
You want it displayed in a certain format, so having a table in your display page and using php to call the data from the server in each cell would accomplish that...a php get function where the cell data in the table is...  You would assign a value to each piece of data, write the simple table into the page and use php to call the data into each cell...
[/quote]

I'd definitely recommend you go with the simpler solution that KeeB suggested above. I'll try to explain [b]why[/b] you need to use that function: when you enter text into a textarea (or copy it from a text editor), your newline characters or carriage returns are saved as the character "\n" or "\r" depending on your system. So, in order to get those newlines to be remembered in HTML, you have to translate them to HTML line breaks. That's where the function comes in: nl2br() changes all newline characters to "<br />" tags for display purposes.

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.