Home > Archive > PHP DB > February 2008 > [PHP-DB] Formatting in Text Area
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[PHP-DB] Formatting in Text Area
|
|
| VanBuskirk, Patricia 2008-02-01, 7:10 pm |
| Sorry, I had sent this first to my FileMaker list, but then realized it
was probably more html/php related than database related. FMP is for
FileMaker Pro.
Can you give me an example of your suggestion? I am still quite new at
php and learn much better by example.
Thanks Evert!
Trish
-----Original Message-----
From: Evert Lammerts [mailto:evert.lammerts@gmail.com]=20
Sent: Friday, February 01, 2008 8:21 AM
To: VanBuskirk, Patricia
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Formatting in Text Area
VanBuskirk, Patricia wrote:
> I have a "customer description" text area field on my form which feeds
through php to FMP,
What's FMP? Is that what links this email to the db-list?
> and spits out a confirmation page and email. The issue I am having
is this ... as the customer types, the text wraps. Many put their own
hard returns and spaces in to organize their description. It seems I
can't get it to do both the wrap and show the actual formatting entered.
If I format the field as physical wrap, the lines run off the page on
the confirmation/printout. If I format it as virtual, then the hard
returns, etc get lost. I have also tried using <PRE> on the
confirmation page and email and that doesn't work either.
> =20
Line wrapping in a text area is a property of the text area, not of the=20
text, as opposite to line breaks and hard returns. This is why you won't
find line break characters at the place the text used to wrap in the=20
text area.
What you can do of course is to add a div (or whatever container you=20
feel like) of the same width / height as the text area to the=20
confirmation page and replace \l\r with br 's.
| |
| Bastien Koert 2008-02-01, 7:10 pm |
|
$text = nl2br($text);
bastien
> Date: Fri, 1 Feb 2008 08:07:17 -0500> From: pvanbuskirk@otc.fsu.edu> To: php-db@lists.php.net> Subject: [PHP-DB] Formatting in Text Area> > I have a"customer description" text area field on my form which feeds through php to FMP, and spits out a confirmation page and email. The issue I am having is this ... as the customer types, the text wraps. Many put their own hard returns and spaces in to organize their description. It seems I can't get it to do both the wrap and show the actual formatting entered. If I format the field as physical wrap, the lines run off the page on the confirmation/printout. If I format it as virtual, then the hard returns, etc get lost. I have also tried using <PRE> on the confirmation page and email and that doesn't work either.> > Hmmm... scratching head!> > Trish> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~> Patricia Van Buskirk> Florida State University, Office of Telecommunications> 644 W. Call Street> Tallahassee, FL 32306-1120>(850) 644-9247> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~> > -- > PHP Database Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>
________________________________________
_________________________
| |
| Tobias Franzén 2008-02-01, 7:10 pm |
| Hi Patricia,
You can impose width restrictions on the textarea field and forcefully
wrap lines longer than the desired length afterwards (if you save it,
save it as-is for better portability). To wrap text with PHP when you
print it, or want to send the e-mail, there is a function called
wordwrap(). Be sure to split the string at every line break though.
Using white-spaces for formating will only work if your output of the
text is with a fixed-width font. The <pre> html tag will do this for
you, but it won't look pretty. Use CSS to style it is my advise.
Something to bear in mind with regards to e-mail is that the "standard"
line width is 72 characters if I remember correctly.
Comparison of fixed-width fonts
http://www.cfcl.com/vlb/h/fontmono.html
Example code (not tested, so I'm not sure it will run as-is):
<?php
$text = $_POST["textareainput"];
$long_lines = split("\n", $text);
$split_text = "";
$width = 72;
foreach ($long_lines as $oneline) {
$split_text = $split_text . wordwrap($oneline, $width, "\n") . "\n";
}
// $split_text will have one more newline at the end than what you
started with, so let's clean it up
$split_text = substr($split_text, 0, -1);
echo "<pre>" . $split_text . "</pre>";
// or
echo nl2br($split_text);
?>
/Tobias
VanBuskirk, Patricia wrote:
> Sorry, I had sent this first to my FileMaker list, but then realized it
> was probably more html/php related than database related. FMP is for
> FileMaker Pro.
>
> Can you give me an example of your suggestion? I am still quite new at
> php and learn much better by example.
>
> Thanks Evert!
>
> Trish
>
> -----Original Message-----
> From: Evert Lammerts [mailto:evert.lammerts@gmail.com]
> Sent: Friday, February 01, 2008 8:21 AM
> To: VanBuskirk, Patricia
> Cc: php-db@lists.php.net
> Subject: Re: [PHP-DB] Formatting in Text Area
>
> VanBuskirk, Patricia wrote:
>
> through php to FMP,
> What's FMP? Is that what links this email to the db-list?
>
> is this ... as the customer types, the text wraps. Many put their own
> hard returns and spaces in to organize their description. It seems I
> can't get it to do both the wrap and show the actual formatting entered.
> If I format the field as physical wrap, the lines run off the page on
> the confirmation/printout. If I format it as virtual, then the hard
> returns, etc get lost. I have also tried using <PRE> on the
> confirmation page and email and that doesn't work either.
>
> Line wrapping in a text area is a property of the text area, not of the
> text, as opposite to line breaks and hard returns. This is why you won't
>
> find line break characters at the place the text used to wrap in the
> text area.
>
> What you can do of course is to add a div (or whatever container you
> feel like) of the same width / height as the text area to the
> confirmation page and replace \l\r with br 's.
>
>
| |
|
| i'm just add Tobias script.
put "rtrim" and "ltrim" to have a better result.
----- Original Message -----
From: "Tobias Franzén" <lists.zxinn@otaking.se>
To: <php-db@lists.php.net>
Sent: Friday, February 01, 2008 10:24 PM
Subject: Re: [PHP-DB] Formatting in Text Area
> Hi Patricia,
>
> You can impose width restrictions on the textarea field
and forcefully
> wrap lines longer than the desired length afterwards (if
you save it,
> save it as-is for better portability). To wrap text with
PHP when you
> print it, or want to send the e-mail, there is a function
called
> wordwrap(). Be sure to split the string at every line
break though.
>
> Using white-spaces for formating will only work if your
output of the
> text is with a fixed-width font. The <pre> html tag will
do this for
> you, but it won't look pretty. Use CSS to style it is my
advise.
>
> Something to bear in mind with regards to e-mail is that
the "standard"
> line width is 72 characters if I remember correctly.
>
> Comparison of fixed-width fonts
> http://www.cfcl.com/vlb/h/fontmono.html
>
> Example code (not tested, so I'm not sure it will run
as-is):
> <?php
> $text = $_POST["textareainput"];
> $long_lines = split("\n", $text);
> $split_text = "";
> $width = 72;
> foreach ($long_lines as $oneline) {
> $split_text = $split_text . wordwrap($oneline, $width,
"\n") . "\n";
> }
> // $split_text will have one more newline at the end than
what you
> started with, so let's clean it up
> $split_text = substr($split_text, 0, -1);
> echo "<pre>" . $split_text . "</pre>";
> // or
> echo nl2br($split_text);
> ?>
>
> /Tobias
>
> VanBuskirk, Patricia wrote:
then realized it[color=darkred]
related. FMP is for[color=darkred]
still quite new at[color=darkred]
form which feeds[color=darkred]
db-list?[color=darkred]
issue I am having[color=darkred]
put their own[color=darkred]
description. It seems I[color=darkred]
formatting entered.[color=darkred]
off the page on[color=darkred]
then the hard[color=darkred]
the[color=darkred]
either.[color=darkred]
area, not of the[color=darkred]
is why you won't[color=darkred]
wrap in the[color=darkred]
container you[color=darkred]
to the[color=darkred]
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
|
|
|
|
|