Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Multi-line text area

New Here ,
Aug 27, 2007 Aug 27, 2007
Hi There,

I am developing a CMS with php/mysqI and dreamweaver . I'm at the stage of testing forms out in my apache testing server. I'm specifically having some issues with a multi-line text area in a php form called addNews.php. I want to be able to add content to this text area which can have 4 or five paragraphs, however during testing, when I write an article which has multiple paragraphs, it appears on the content page unformatted without the paragraph gaps?

Before I have used a KTML editor from Interaktonline and I know that this will do the job, however I just want to be able to add content with a simple text area.

Why does this happen? Is there a way round this so I can just have the simple text area that can handle paragraphs?

regards
orange22
TOPICS
Server side applications
337
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2007 Aug 27, 2007
orange22 wrote:
> Why does this happen? Is there a way round this so I can just have the simple
> text area that can handle paragraphs?

If you switch to source view in the browser, you will see that the new
lines are there. However, HTML ignores excess whitespace and new line
characters. That's why your paragraphs don't show up.

There are two ways around this:

1. Use nl2br() to format the output. This converts the new line
characters to <br /> tags. If you're using Dreamweaver CS3, you can
select Convert - New Lines to BRs from the Format menu in the Dynamic
Text dialog box. In earlier versions of DW, you need to hand-code it.
Just surround the variable containing the article like this:

echo nl2br($row_recordsetName['article']);

2. The alternative is to place opening and closing <p> tags at the
beginning and end of the article. Then use str_replace() to replace
every pair of double new lines with </p><p>.

<p><?php echo str_replace("\n\n", '</p><p>',
$row_recordsetName['article']); ?></p>

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2007 Aug 28, 2007
Hi David,

Yet again your reply is first class!!! You gave me the exact solution to my problem and it was so well explained that I was able to make the change to the php code in 2 minutes - thank you very much.

Kind regard
orange22
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2007 Aug 28, 2007
LATEST
orange22 wrote:
> Yet again your reply is first class!!! You gave me the exact solution to my
> problem and it was so well explained that I was able to make the change to the
> php code in 2 minutes - thank you very much.

Glad to be of help.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines