textarea pb.....

General discussions related to php

Moderators: macek, egami, gesf

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

textarea pb.....

Postby cho@ » Thu Aug 15, 2002 2:58 am

i have my text area...

i wonder how i can recongnise that the user press enter (char(13) or s/thing like dat)...

cuz after i store this info in a DB (mysql) and when i put it back on a HTML page i wanna go to the line...like in the text area..

i ve tried $var = str_replace('\r\n','<br>',$fieldname);

but it doesn't work..

in fact how is the cariage return coded?

thx all

cho@

elitecodex
New php-forum User
New php-forum User
Posts: 68
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA
Contact:

Postby elitecodex » Thu Aug 15, 2002 3:08 am

Do this:

$fieldname = nl2br($fieldname);

and all your worries are over :) It does just what it says (converts newlines 2 <br>'s

PHP Reference: http://www.php.net/nl2br

Have Fun !!

Will

Jay

Postby Jay » Thu Aug 15, 2002 3:20 am

To display new lines in a text area you have to use the html entity for a new line which is &#10;. <br> won't work, that's for normal text, not text areas!

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby cho@ » Thu Aug 15, 2002 7:08 am

to:elitecodex

thx for the thingy it works very well... :wink:

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

Postby cho@ » Thu Aug 15, 2002 7:10 am

to:Jay


sorry i might have not very well express my needs...
in fact i dont wanna display the results in an other texarea...
(not now)..
if i want it l8er then..thx for the thingy...i ll remember.. :wink:


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron