473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Keeping the formatting of text

Probably a simple solution to this one

When I display large piece of text on a web page from a text field in my
database the formatting such as paragraphs line feeds are lost, unless I
include the appropriate html tags in it. How can I display the text as
written initially?

Thanks in advance
Aug 2 '06 #1
9 1408

Ian Davies wrote:
Probably a simple solution to this one

When I display large piece of text on a web page from a text field in my
database the formatting such as paragraphs line feeds are lost, unless I
include the appropriate html tags in it. How can I display the text as
written initially?

Thanks in advance
Perhaps <pre></prearound the text.

Flamer.

Aug 2 '06 #2
flamer di******@hotmail.com wrote:
Ian Davies wrote:

>Probably a simple solution to this one

When I display large piece of text on a web page from a text field in my
database the formatting such as paragraphs line feeds are lost, unless I
include the appropriate html tags in it. How can I display the text as
written initially?

Thanks in advance

Perhaps <pre></prearound the text.
Or use nl2br($text) to convert line breaks to <br>.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Everyone's journey should be different,
so that we all are enriched
in new and endless ways
*****************************
Aug 2 '06 #3
In article <Wt******************************@comcast.com>,
Chuck Anderson <we************@seemy.sigwrote:
>flamer di******@hotmail.com wrote:
>Ian Davies wrote:
>>When I display large piece of text on a web page from a text field in my
database the formatting such as paragraphs line feeds are lost, unless I
include the appropriate html tags in it. How can I display the text as
written initially?

Perhaps <pre></prearound the text.

Or use nl2br($text) to convert line breaks to <br>.
That converts line breaks to <br /which doesn't validate as
HTML unless you do str_replace("<br />", "<br>", nl2br($text));
And doing that seems inefficient since nl2br() already performs
str_replace("\n", "<br />", $text). You may as well do the
str_replace yourself and ignore nl2br().

<pre>...</preis probably easier. If you don't want monospaced
font, you can always set the CSS font family for <preto sans-serif
or something.

-A
Aug 2 '06 #4
Message-ID: <ea**********@blue.rahul.netfrom axlq contained the
following:
>That converts line breaks to <br /which doesn't validate as
HTML unless you do str_replace("<br />", "<br>", nl2br($text));
And doing that seems inefficient since nl2br() already performs
str_replace("\n", "<br />", $text). You may as well do the
str_replace yourself and ignore nl2br().
Except that it's not always \n
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Aug 2 '06 #5
Rik
Geoff Berrow wrote:
Message-ID: <ea**********@blue.rahul.netfrom axlq contained the
following:
>That converts line breaks to <br /which doesn't validate as
HTML unless you do str_replace("<br />", "<br>", nl2br($text));
And doing that seems inefficient since nl2br() already performs
str_replace("\n", "<br />", $text). You may as well do the
str_replace yourself and ignore nl2br().

Except that it's not always \n
preg_replace('/(\r\n|\r|\n)/','<br>',$string);

Grtz,
--
Rik Wasmus
Aug 4 '06 #6
Message-ID: <24**************************@news2.tudelft.nlfr om Rik
contained the following:
>Except that it's not always \n

preg_replace('/(\r\n|\r|\n)/','<br>',$string);
Nice one Rik. :-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Aug 4 '06 #7
Thank you everyone that has given me a number of options to try
"Geoff Berrow" <bl******@ckdog.co.ukwrote in message
news:24********************************@4ax.com...
Message-ID: <24**************************@news2.tudelft.nlfr om Rik
contained the following:
Except that it's not always \n
preg_replace('/(\r\n|\r|\n)/','<br>',$string);

Nice one Rik. :-)

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Aug 4 '06 #8
ax**@spamcop.net (axlq) wrote:
>
>>Or use nl2br($text) to convert line breaks to <br>.

That converts line breaks to <br /which doesn't validate as
HTML unless you do str_replace("<br />", "<br>", nl2br($text));
Interesting. I hadn't realized that form wasn't in the HTML standard.
Every browser in the world will accept <br/>, and it is required for XHTML.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 6 '06 #9
>>Or use nl2br($text) to convert line breaks to <br>.
>
That converts line breaks to <br /which doesn't validate as
HTML unless you do str_replace("<br />", "<br>", nl2br($text));
"Tim Roberts" <ti**@probo.comwrote:
Interesting. I hadn't realized that form wasn't in the HTML standard.
Every browser in the world will accept <br/>, and it is required for
XHTML.
Do you know if the extra space in the <br /was required at one time?
I just tested a page with <br/and it validated as XHTML Transitional,
XHTML Strict, and HTML Strict and and it doesn't seem to be required.
For some reason though, I've always put that extra space in. I'm now
wondering why I put it in there...

HTML Strict doesn't validate the <meta /tags in the header and requires
the meta tags configured as follows:

<meta name="description" content="test">

However, the closed /tags validate (<br /and <img />) when they're
in the body (HTML 4.0 Strict).

--
Jim Carlock
Post replies to the group.
Aug 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rob Meade | last post by:
Hi all, Ok - this leads on from speaking to a couple here and in the SQL server group... I've an application which allows the user to type in their text into a form, they add 'happy' tags...
4
by: Dr. Laurence Leff | last post by:
I am writing a Java program to read in XML file, modify some elements slightly, and then write it out. That XML file is prepared in Docbook. It works fine, except that it is disturbing the...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
14
by: Scott M. | last post by:
Ok, this is driving me nuts... I am using VS.NET 2003 and trying to take an item out of a row in a loosely-typed dataset and place it in a label as a currency. As it is now, I am getting my...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
1
by: aman909 | last post by:
Hello, Im trying to use conditional formatting in a text box on a form. What im trying to do is that conditional formatting changes the colour of the text in the text box. I need the...
3
by: =?Utf-8?B?b24tbGluZSBqb3VybmFsIGVkaXRvcg==?= | last post by:
I can't seem to cut-and-paste text, with either .doc or .html formatting, into my .asp web-pages --all the formatting is lost. Is there some code that needs to be added to the page that will...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.