[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-22-2005, 12:19 AM   #1 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
 
Join Date: Apr 2004
Location: IL
Posts: 339
50.00 NP$ (Donate)

TwiztedFake is on a distinguished road


PHP help.

How do I insert line breaks into a text area form input when a users hits the enter to start a new line.

The form is submited via PHP to be stored in a database. Everything works fine just needing to know how to insert the line breaks.
__________________
Four Seasons Outfitters
[ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ]
[ 25 $NP/Month] [ 25 $NP/Month]
TwiztedFake is offline  
Old 12-22-2005, 01:52 AM   #2 (permalink)
NamePros Regular
 
Join Date: Oct 2005
Posts: 231
223.75 NP$ (Donate)

Immersion is an unknown quantity at this point


cant you do '/n' or something
Immersion is offline  
Old 12-22-2005, 04:22 AM   #3 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,285
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer
\r\n
__________________
Buy now - MassDeveloper.com $500
sdsinc is offline  
Old 12-22-2005, 07:41 AM   #4 (permalink)
NamePros Member
 
Join Date: Nov 2005
Posts: 126
149.90 NP$ (Donate)

cx409 is an unknown quantity at this point


If you're talking how to show 'Enters' submitted by a form into pure HTML, use the php function nl2br:

PHP Code:
$str = $user_submitted_thing_with_line_breaks;
$new_str = nl2br($str);
It will make all line breaks into <br />'s
cx409 is offline  
Old 12-22-2005, 07:42 AM   #5 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
presumably you are having problems of the text only showing on 1 line when you rtetrieve it back from the database.

If that is the case run the variable through nl2br(). This changes the new line char to the <br> which html needs.
Peter is offline  
Old 12-22-2005, 09:33 AM   #6 (permalink)
Eating Pie
 
iNod's Avatar
 
Join Date: Nov 2004
Location: Canada
Posts: 2,289
126.05 NP$ (Donate)

iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of

Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
It depends what you want to do with the results from the textarea. If you wish to display it as text either nl2br or wordwrap will work. If you wish to store it in mysql db I would probley use nl2br. If you don't need to do anything but store it to be used in another textarea nothing is needed.

iNod.
__________________
I feel old.
iNod is offline  
Old 12-22-2005, 09:49 AM   #7 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
 
Join Date: Apr 2004
Location: IL
Posts: 339
50.00 NP$ (Donate)

TwiztedFake is on a distinguished road


Thanks everyone I used nl2br() and it works just how I wanted. I store the information in the database then it is displayed on a page at a later time.

I gave everyone 10 np's for helping.
__________________
Four Seasons Outfitters
[ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ]
[ 25 $NP/Month] [ 25 $NP/Month]
TwiztedFake is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tutorial: Getting started with PHP (The Basics) deadserious Webmaster Tutorials 60 11-17-2007 11:35 AM
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 09:09 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 06:52 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85