Html Wordwrap issue for mysql db!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Html Wordwrap issue for mysql db!

Post by cap2cap10 »

Greetings again, members of the php technorati. How do I get form data to be saved in db with line breaks? I used wordwrap= virtual but it doesn't work! all lines are connected to each other in one continuous string! This is probably a noob issue but please enlighten me! I refuse to ask the user to add in <br> and <p>! Help me to help them make their form usage less complicated!

Thanks in advance,

Batoe
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Html Wordwrap issue for mysql db!

Post by requinix »

Use nl2br when you display the text. Not when you put it into the database.
Because it already has the line breaks. The issue is that HTML will automatically collapse spaces and line breaks into a single space (unless told otherwise with the white-space CSS... thing).
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Html Wordwrap issue for mysql db!

Post by oscardog »

cap2cap10 wrote:Greetings again, members of the php technorati. How do I get form data to be saved in db with line breaks? I used wordwrap= virtual but it doesn't work! all lines are connected to each other in one continuous string! This is probably a noob issue but please enlighten me! I refuse to ask the user to add in <br> and <p>! Help me to help them make their form usage less complicated!

Thanks in advance,

Batoe
Alternatively, you can use a free WYSIWYG editor like TinyMCE or my personal favourite; CKEditor. This will automatically format in the paragraph tags etc.
Post Reply