Forums | MacLife
You are not logged in.
#1 2005-01-20 9:52 pm
MySQL and line breaks
I'm working on a site for a business association and I'm feeling pretty proud because it's the first site I've done with PHP and MySQL. I've set it up so that it is entirely updatable using a MySQL database so that they can add new members or just update their pages without contacting me.
I have it set up so the user enters text on an administration page, which submits it into a MySQL database. When the page loads, it retrieves the data. Is there any way that I can get the page to process linebreaks? The line breaks appear in the MySQL database but are obviously not processed when it is processed to HTML. I'd really rather not tell them they have to type the html line break command on the page every time they want a new paragraph. Any suggestions? Thanks.
Offline
#2 2005-01-20 9:54 pm
- disturbed_child
- Member

- From: a dark alleyway
- Registered: 2003-02-05
- Posts: 766
- Website
Re: MySQL and line breaks
Use the php function
Code:
nl2br($text);
It will convert line breaks ( \n ) to html line breaks ( <br /> ).
If that's quite not what you're looking for, you could do some crazy stuff with
Code:
str_replace($search, $replace_with, $text);
Hope that's what you'er looking for.
Offline

