RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 6717 | Replies: 3 | Thread Tools  Display Modes
Reply
Join Date: Jun 2005
Posts: 3
Reputation: Juls is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Juls Juls is offline Offline
Newbie Poster

Help Output MySQL text field formatted

  #1  
Aug 30th, 2005
Hi,

I have a text data type field in MySQL table that I need to read out to a page. When the value is entered into this text field the value will have returns as follows:

------------------
TEST TEST aaaaaaaa

asdasdasdfas

3rd lineasadas
----------------
When I read this value out and display in php page in the browser, the returns are not there and I get it all in one line:
-----------------------
TEST TEST aaaaaaaaasdasdasdfas3rd lineasadas
-------------------

What can I do to have he returns show up?

Thanks,
Juls
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Output MySQL text field formatted

  #2  
Sep 1st, 2005
In the webpage you can use str_replace:

$text = $row['text'];
$text = str_replace("\n", "<br>", $text);
echo $text;

To prnt in one line, ignore the str_replace part.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Aug 2005
Posts: 22
Reputation: ashwinperti is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ashwinperti ashwinperti is offline Offline
Newbie Poster

Installation MySql

  #3  
Sep 2nd, 2005
Sir,

I am new to MySql.

I am facing Installation Problem.

Kindly do the Needful.

Ashwin Perti
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Output MySQL text field formatted

  #4  
Sep 3rd, 2005
Juls - PHP has a built in function to convert line feeds to <br /> elements. It is nl2br, and it's use is:
[PHP]echo( nl2br("this is a line\nthis is another line") )
/** prints as
this is a line<br />
this is another line
*/[/PHP]

ashwinperti - suggest you start your own thread rather than trying to hijack others. You'll get a better response if you describe what your problem is and what your operating environment is.
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



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

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:13 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC