Output MySQL text field formatted

Reply

Join Date: Jun 2005
Posts: 3
Reputation: Juls is an unknown quantity at this point 
Solved Threads: 0
Juls Juls is offline Offline
Newbie Poster

Output MySQL text field formatted

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Output MySQL text field formatted

 
0
  #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 Quick reply to this message  
Join Date: Aug 2005
Posts: 22
Reputation: ashwinperti is an unknown quantity at this point 
Solved Threads: 0
ashwinperti ashwinperti is offline Offline
Newbie Poster

Installation MySql

 
0
  #3
Sep 2nd, 2005
Sir,

I am new to MySql.

I am facing Installation Problem.

Kindly do the Needful.

Ashwin Perti
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Output MySQL text field formatted

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 11619 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC