Please support our PHP advertiser: Lunarpages PHP Web Hosting
![]() |
•
•
Join Date: Jun 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
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.
$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.
•
•
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation:
Rep Power: 5
Solved Threads: 7
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.
[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 ::
Lafinboy Productions
:: Website Design :: Website Development ::
![]() |
Similar Threads
Other Threads in the PHP Forum
- Inserting date in format DD-MM-YYYY in MySQL (MySQL)
- Text field does not enable on refresh (JavaScript / DHTML / AJAX)
- JSP and Servlet Display of text in a text field (JSP)
- Filtering My sql through Php using drop down menu and text field (PHP)
- getting the text field value (HTML and CSS)
- DOB field-how to use text field and pop out calendar same time? (ASP)
Other Threads in the PHP Forum
- Previous Thread: PHP Installation Help
- Next Thread: Ecommerce Store Directory
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode