| | |
Output MySQL text field formatted
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 3
Reputation:
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
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.
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
- 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
Views: 11619 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class clean cms code countingeverycharactersfromastring cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail match menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions simple sms soap source space spam speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





