Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Add HTML coding from plain text field
Old 01-10-2008, 01:34 PM Add HTML coding from plain text field
Average Talker

Posts: 26
Name: Darren Driver
Trades: 0
Hi all,

I'm not sure if I posted this in the right section, but here goes.

I'm trying to code a news updater to a site, using a HTML form that goes to a PHP page and updates the database from there. It all works fine, I don't need help with with that.

What I would like to know is how do you code it so that, when someone presses return in the HTML form, it adds the <br /> code in that place? When I try it, it doesn't add the new line so the news post just comes out as one, long line.

Thanks!
A17roolz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-10-2008, 02:04 PM Re: Add HTML coding from plain text field
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
You need to format your output with nl2br.

http://uk2.php.net/manual/en/function.nl2br.php
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 01-10-2008, 02:33 PM Re: Add HTML coding from plain text field
Average Talker

Posts: 26
Name: Darren Driver
Trades: 0
But wouldn't the text field need to add "\n" where each <br /> is needed? My system isn't adding those either...
A17roolz is offline
Reply With Quote
View Public Profile
 
Old 01-10-2008, 10:09 PM Re: Add HTML coding from plain text field
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
\n is a switched characture for new line. When you type the "Enter" or "Return" key on the keyboard, it creates a new line, and the built-in PHP function nl2br() is placing the html tag <br /> before each newline within the string.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 05:24 AM Re: Add HTML coding from plain text field
Average Talker

Posts: 26
Name: Darren Driver
Trades: 0
That works perfectly, thanks guys!

I forgotten how to add Talkputation though, can someone remind me
A17roolz is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 01:47 AM Re: Add HTML coding from plain text field
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
Originally Posted by A17roolz View Post
I forgotten how to add Talkputation though, can someone remind me
Look left. You'll see people's information. At the bottom is a link to add TK.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Add HTML coding from plain text field
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40624 seconds with 12 queries