line breaks
am 31.01.2003 17:22:50 von Tarik Kutluca
Hi,
From a web form I am collecting information to a table. On the form there is
a textarea element storing to a text field on the mysql table. Since the
textarea can hold the enter key, it's stored in to the field also, but when
i try to call that cell and display it on the web page, i see that line
breaks are ignored. But the sentences must be displayed as they are entered.
- what is the stored character code of the enter key in the text field, i am
figuring out to find that character and replace it with the
element,
for the exact display,
- do you have a shorter way to do this?
thank you
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail
To unsubscribe, e-mail
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: line breaks
am 01.02.2003 06:18:54 von Zak Greant
On Fri, Jan 31, 2003 at 06:22:50PM +0200, Tarik Kutluca wrote:
> Hi,
>
> >From a web form I am collecting information to a table. On the form there is
> a textarea element storing to a text field on the mysql table. Since the
> textarea can hold the enter key, it's stored in to the field also, but when
> i try to call that cell and display it on the web page, i see that line
> breaks are ignored. But the sentences must be displayed as they are entered.
>
> - what is the stored character code of the enter key in the text field, i am
> figuring out to find that character and replace it with the
element,
> for the exact display,
>
> - do you have a shorter way to do this?
When HTML agents display text, they are supposed to fold all
whitespace characters (newlines, tabs, spaces) into a single space
character unless the text is contained in a
block.
The characters that make up a new line sequence vary depending on
the operating system of the client. Unix-like OSs use ASCII
character code 10, Windows uses 13 followed by 10 and Macs (but
likely not OS X+) use 13.
If you are using PHP, just call nl2br() on the text before you
display the text.
Cheers!
--
Zak Greant | MySQL Advocate | http://zak.fooassociates.com
MySQL Tip: Show the configuration options set in the server
% mysqld --print-defaults
My punctuality is well known. When the revolution takes place, I'll be late
and I'll be shot as a traitor.
--Traitor by the SugarCubes
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail
To unsubscribe, e-mail
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: line breaks
am 01.02.2003 06:24:25 von Benjamin Pflugmann
Hi.
In which way is this a MySQL related problem? Please choose a more
appropriate forum next time.
On Fri 2003-01-31 at 18:22:50 +0200, tarik@kult.com.tr wrote:
> Hi,
>
> >From a web form I am collecting information to a table. On the form there is
> a textarea element storing to a text field on the mysql table. Since the
> textarea can hold the enter key, it's stored in to the field also, but when
> i try to call that cell and display it on the web page, i see that line
> breaks are ignored. But the sentences must be displayed as they are entered.
>
> - what is the stored character code of the enter key in the text field, i am
> figuring out to find that character and replace it with the
element,
> for the exact display,
Depends on the browser used to enter the text. Usually it's '\n'
(i.e. the character with code 10 resp. hex 0x0A)
> - do you have a shorter way to do this?
Not really, except if you are happy with using
Bye,
Benjamin.
--
benjamin-mysql@pflugmann.de
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail
To unsubscribe, e-mail
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: line breaks
am 01.02.2003 10:33:06 von list_hinz
Tarik,
> - what is the stored character code of the enter key in the text
field, i am
> figuring out to find that character and replace it with the
element,
> for the exact display,
The character is "\n" (the new line character).
If you use PHP and have magic_quotes=on in your php.ini, PHP will
automatically escape certain characters like \n. If magic_quotes=off,
you can use the addslashes() function to accomplish this.
When retrieving the data out of MySQL to display them in a textarea
field once again, you have to do nothing. The web browser will take care
of converting \n into something the operating thinks is a new line
(Unix: \n, Windows: \r\n, MacOS: \r). If you want to display the data
outside of form fields, you will have to convert \n into something HTML
knows is a new line. HTML uses for example
or
for this. In PHP,
you can use the nl2br() function that will convert \n into
.
If you don't use PHP, things might be a bit more complicated.
Regards,
--
Stefan Hinz
Geschäftsführer / CEO iConnect GmbH
Heesestr. 6, 12169 Berlin (Germany)
Tel: +49 30 7970948-0 Fax: +49 30 7970948-3
----- Original Message -----
From: "Tarik Kutluca"
To:
Sent: Friday, January 31, 2003 5:22 PM
Subject: line breaks
> Hi,
>
> From a web form I am collecting information to a table. On the form
there is
> a textarea element storing to a text field on the mysql table. Since
the
> textarea can hold the enter key, it's stored in to the field also, but
when
> i try to call that cell and display it on the web page, i see that
line
> breaks are ignored. But the sentences must be displayed as they are
entered.
>
> - what is the stored character code of the enter key in the text
field, i am
> figuring out to find that character and replace it with the
element,
> for the exact display,
>
> - do you have a shorter way to do this?
>
> thank you
>
>
> ------------------------------------------------------------ ---------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail
> To unsubscribe, e-mail
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail
To unsubscribe, e-mail
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php