Jump to content

Recommended Posts

I have a form that puts text into a MySql database. The text can contain carrage returns to create paragraphs.

When I echo the text into a text area, all looks OK.

BUT

When I echo the text direct, the line breaks do not work and everything appears in one line.

How do I echo the text so it appears correctly, including line breaks, without placing in in a text area tag???

Example:-
this works
[code]<textarea name="textfield" cols="70" rows="12"><?php echo $row_Recordset1['Description']; ?></textarea>[/code]

this don't work
[code]<?php echo $row_Recordset1['Description']; ?>[/code]

Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/5153-a-stupid-newbie-question/
Share on other sites

[!--quoteo(post=355888:date=Mar 17 2006, 10:44 AM:name=webwiese)--][div class=\'quotetop\']QUOTE(webwiese @ Mar 17 2006, 10:44 AM) [snapback]355888[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi,

nl2br($yourtext) transaltes linebreaks into <br>.
[/quote]

Thanks Webwiese, works exactly how I want.

Thanks again!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.