rajya vardhan
rajya vardhan

Reputation: 1131

html textarea showing 'mysql text/varchar' in unformatted manner

Using CGI and HTML:

<textarea name=comments rows="6" cols="40" wrap="soft"> 
$hash_ref->{'notes'}
</textarea>

Mysql column has value -> 'hi there'

textarea showing as

 <lot of spaces before>hi there<lot of spaces after>

Post shows as ->

comments=+%0D%0A%09+hi+there+%0D%0A%09+

How can i get the text exactly the same as in database? Please help.

*Solution***
Funny...i changed code from:

 <textarea name=comments rows="6" cols="40" wrap="soft"> 
    $hash_ref->{'notes'}
    </textarea>

To:

<textarea name=comments rows="6" cols="40" wrap="soft">$hash_ref->{'notes'}</textarea>  

And it worked :)

Upvotes: 0

Views: 194

Answers (1)

alex
alex

Reputation: 490453

Can you use trim() before you echo it? It will remove leading and trailing whitespace.

Upvotes: 1

Related Questions