HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 30th, 2000, 01:27 PM
Dr_E_lectric Dr_E_lectric is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 36 Dr_E_lectric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
I have a textarea in a form that a user fills in and then stores the text in mysql as medimum blob and when the users web page is call by any one the data from the db is inserted in to the page content via <?php echo $var ?> .
The problem is how the text is displayed. There is no formating to the text is only a string. How can this text be formated by the user. I am open to suggestions to a better method to the end.

What I want to do is like the way you post this message

Thanks

------------------
Thanks Dr.E.L.

Reply With Quote
  #2  
Old May 30th, 2000, 02:20 PM
MeijdenB MeijdenB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Location: Alkmaar, The Netherlands
Posts: 123 MeijdenB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Let them use HTML within your textarea and store this along with the text. If you echo this the browser will interpret this as normal HTML and so it is formatted.

------------------
Good luck,
Bas

------------------
E-mail me at: b.vandermeijden@pecoma.nl

Reply With Quote
  #3  
Old June 7th, 2000, 09:08 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Here's a couple of ideas:

(1) use <pre> tags around the text when it's
put back into a web page. The users line
breaks are still in there, HTML just
ignores them.

(2) Since you're using PHP you could use
something like newline_to_br() to fix
up the text, or even write your own
routine to convert multiple newlines
into <p>'s.

Personally, I'd probably just use the <pre>
tags.

Scott

Reply With Quote
  #4  
Old June 7th, 2000, 10:20 PM
Dr_E_lectric Dr_E_lectric is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 36 Dr_E_lectric User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Scott, Thanks for the help I will give it a try. How would I apply newline_to_br() <? echo $var; ?>

Bill

Reply With Quote
  #5  
Old July 13th, 2000, 04:32 PM
rev rev is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: cranbrook BC canada
Posts: 12 rev User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to rev
thank you so much for <pre> tags.

they just saved my life.

Reply With Quote
  #6  
Old July 31st, 2000, 12:55 AM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 43
The PHP function is actually called nl2br()

If your string is called $textentry, you could just do:

<?

echo nl2br($textentry);

?>

This would output the string with a <br> where every carriage return was.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Textarea formating


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway