Jump to content


Photo

echo data from textarea on seperated lines.


  • Please log in to reply
4 replies to this topic

#1 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 04 May 2006 - 12:15 PM

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 May 2006 - 01:00 PM

Yes the following is the correct sytax
echo nl2br ($row ['Notes']);
But remove the space between $row and ['Notes'] in the above code so it is just:$row['Notes']

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?

#3 wlpywd

wlpywd
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 02 March 2007 - 12:48 AM

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!


#4 Toshiba23

Toshiba23
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationSan Diego (The place on fire)

Posted 02 March 2007 - 01:20 AM

try this

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

"We can't solve problems with the same thinking we used when we created them." - Albert Einstein

#5 wlpywd

wlpywd
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 02 March 2007 - 01:33 AM

Thanks! its working!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users