General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old December 22nd, 2002, 08:11 PM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 6
Send a message via AIM to Vasarab69
Post auto-insert html "br" at end of line in database entries

on a script that i wrote solely for myself (simple reminders script with content feed or whatnot lol), i was wondering how, when someone presses enter thus making a new line, the html code "br" or "p" can automatically be entered??
__________________
-Alexander

Reply With Quote
  #2  
Old December 22nd, 2002, 09:01 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
nl2br()

this will convert \r\n to <br>

so when you hit enter it will replace that with <br>

Reply With Quote
  #3  
Old December 22nd, 2002, 09:22 PM
Vasarab69 Vasarab69 is offline
Goldmember
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 71 Vasarab69 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 25 sec
Reputation Power: 6
Send a message via AIM to Vasarab69
where do i enter nl2br() ?

Reply With Quote
  #4  
Old December 22nd, 2002, 11:51 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
when you submit the data, lets say from a textarea called test

echo nl2br($_POST['test']);

This would print the variable with br tags

Reply With Quote
  #5  
Old December 23rd, 2002, 05:20 AM
DDDooGGG DDDooGGG is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Melbourne, Australia
Posts: 97 DDDooGGG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 33 sec
Reputation Power: 6
try this
function ReplaceStr($str)
{
$str = ereg_replace("\r\n", "<br>", $str);
echo $str;
}

call this function like this

ReplaceStr($myrow['textfield']);
__________________
regards,


Fulton

Reply With Quote
  #6  
Old December 23rd, 2002, 07:56 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
dog, that does the exact same thing as nl2br, so why redifine a function that already exists?? The only difference between your function and nl2br, is that your functions echos the data, while nl2br returns the value. which just means you have to echo the function.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > auto-insert html "br" at end of line in database entries


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 | 
  
 

Iron Speed




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