Jump to content

[SOLVED] outputting text


Giddy Rob

Recommended Posts

Hey,

 

I have some text data in a database that im outputting to a page. The text is made up of two paragraphs divided by a line space i.e.

 

"rar rar rar.

 

rar rar rar"

 

When I use mysql_fetch_array to get the value out of the database it gets rid of the spacing i.e.

 

"rar rar rar. rar rar rar"

 

I have checked in the database and it conserves the line spacing so I guess it must be something to do with the php?

 

Is there a way i can output the value with the line spacing intact?

 

Any help would be great.

 

Cheers

 

Rob  ???

Link to comment
https://forums.phpfreaks.com/topic/37605-solved-outputting-text/
Share on other sites

Thorpe is definitely pointing you at the right function, but I wanted to give a little more explanation. When you depress the enter key within a text area, you are simply applying a newline character ('\n') to the text. The function thorpe has pointed you to changes those newline characters to <br /> tags, hence cleaning up your HTML output. Now, keep in mind that when exporting source code, plain text and/or text emails, you need to use '\n' or '\r\n' (Windows safe) to designate linebreaks.

Thanks for the reply, but depending on the record depends where the line spacing is (if any) so it needs to be done automatically if possible?

 

I am basically using one page that gets fed a record from a database depending on the id number so some text might be just one paragraph, but also there might be three! It all depends on what the user has put in the database. I would like it to be able to detect the spacing and put \r\n.

 

Is this possible?

 

Cheers

 

Rob  ;D

 

 

Thanks for the reply, but depending on the record depends where the line spacing is (if any) so it needs to be done automatically if possible?

 

I am basically using one page that gets fed a record from a database depending on the id number so some text might be just one paragraph, but also there might be three! It all depends on what the user has put in the database. I would like it to be able to detect the spacing and put \r\n.

 

Is this possible?

 

Cheers

 

Rob  ;D

 

 

 

That's what the function thorpe showed you does. It finds the line breaks that the users have inserted into their text and changes them to <br /> tags.

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.