Jump to content

Archived

This topic is now archived and is closed to further replies.

crazylegseddie

echo data from textarea on seperated lines.

Recommended Posts

Hi everyone, just a simple displaying problem.
if I insert information using a textarea

<textarea name="Notes" cols="50" rows="6" class="box"></textarea>

and display information using:

echo $row ['Notes'];

All the data inputed remains on 1 line. Ive tried

echo nl2br ($row ['Notes']);

but think ive got the syntax wrong. Any help with this would be good. thank you

Share this post


Link to post
Share on other sites
Yes the following is the correct sytax
[code]echo nl2br ($row ['Notes']); [/code]
But remove the space between $row and ['Notes'] in the above code so it is just:[b]$row['Notes'][/b]

Also I presume you are getting $row['Notes'] from a database? And any data that is submitted from the textarea is added into the database?

Share this post


Link to post
Share on other sites
I am having i think the same problem, and trying not to start new topics on same posts.  I have a form inserting data into a mysql database, and on the page where i call the data, a simple tabled list of the data displayed, anything entered in the "textarea" box is displayed as one long sentence instead of displaying where someone typed 'enter' key.  So display is like this:

Jon Smith 554 main Anytown USA 

instead of:

Jon Smith
554 main
Anytown USA

I have tried adding this code, with the space taken out, to my code but it does not seem to work.  Is there more to it i need to do rather than whats shown here on my display page to get it to work correctly?  (i am fairly new to php...)

thanks anyone!

Share this post


Link to post
Share on other sites
try this

print str_replace("\n", "<br>", $row['NOTES']);

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.