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
Old 11-24-2004, 06:15 AM Forms formatting
Novice Talker

Posts: 7
Trades: 0
When I submit a form to the sql database it leaves out paragraph breaks in the form.

Is there a way to maintain the formating of the form submited so that it does not just string all the words together where there are line and paragraph breaks?

Cheers
live-undead is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-24-2004, 07:54 AM
Snowblind's Avatar
Skilled Talker

Posts: 80
Location: New Zealand
Trades: 0
There sure is. For breaks put a simple \n at the end of each paragraph.
__________________
Snowblind \m/

Please login or register to view this content. Registration is FREE
Snowblind is offline
Reply With Quote
View Public Profile
 
Old 11-24-2004, 12:11 PM
Gary_Pinkett's Avatar
Junior Talker

Posts: 4
Trades: 0
Adding a \n manually is donkey work! A better way of doing it would be use a PHP command when viewing the content from the database, or before updating or inserting. I personally prefer to do it when outputting the content. Anyway, the command is "nl2br".

This basically converts the linebreaks to <BR>'s, sorted!
Gary_Pinkett is offline
Reply With Quote
View Public Profile Visit Gary_Pinkett's homepage!
 
Old 11-24-2004, 12:24 PM
techwench's Avatar
Code Monkey

Posts: 1,449
Name: Danalyn
Location: Dallas, TX
Trades: 0
Yeah, to elaborate on what Gary said, when you enter in the form, line breaks get translated to \n. Use the php function nl2br() to echo your string back, and it will automatically convert line breaks to the <br /> tag.

PHP Code:
echo nl2br($string); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
techwench is offline
Reply With Quote
View Public Profile
 
Old 11-24-2004, 01:15 PM
Novice Talker

Posts: 7
Trades: 0
Cheers guys!
live-undead is offline
Reply With Quote
View Public Profile
 
Old 06-14-2007, 11:07 AM Re: Forms formatting
Daman's Avatar
Extreme Talker

Posts: 157
Location: Toronto, CANADA
Trades: 0
I am trying to get this to work with in html embedded in php. Here is what i resulted but does not work. Can some correct this for me please?

<? <p class=\"questions\">"print nl2br($q2_3);"</p> ?>
Daman is offline
Reply With Quote
View Public Profile Visit Daman's homepage!
 
Old 06-14-2007, 11:12 AM Re: Forms formatting
Raulică's Avatar
Ultra Talker

Posts: 253
Location: Constanta,Romania
Trades: 0
or
PHP Code:
<? echo(ereg_replace("\n","<br>",$string)); ?>
__________________

Please login or register to view this content. Registration is FREE

Professional hosting for all pockets!

Please login or register to view this content. Registration is FREE
Raulică is offline
Reply With Quote
View Public Profile Visit Raulică's homepage!
 
Old 06-14-2007, 12:11 PM Re: Forms formatting
Daman's Avatar
Extreme Talker

Posts: 157
Location: Toronto, CANADA
Trades: 0
This html...
HTML Code:
<p class=\"questions\"><? echo nl2br($q2_3); ?> </p>
is embedded in php delimeter. I need to make...
PHP Code:
echo nl2br($q2_3); 
work in this format exactly. I hope this is clear.
Daman is offline
Reply With Quote
View Public Profile Visit Daman's homepage!
 
Old 06-14-2007, 12:39 PM Re: Forms formatting
Daman's Avatar
Extreme Talker

Posts: 157
Location: Toronto, CANADA
Trades: 0
here is another example of what i need to correct
PHP Code:
echo '<a href=\"nl2br ($q1)\"></a>'
Daman is offline
Reply With Quote
View Public Profile Visit Daman's homepage!
 
Reply     « Reply to Forms formatting
 

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.28491 seconds with 12 queries