Quantcast

Forums | MacLife

You are not logged in.

#1 2005-01-20 9:52 pm

iZach004
Member
From: Indianapolis, IN, 46240
Registered: 2001-06-04
Posts: 176
Website

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.


Have we lost everything now? / Walking like each other's ghosts around these silent streets / The sedatives tell you everything is alright / Like calendars dying at new year's eve parties
As we kiss hard on the lips and swear, "this year will be better than the last"
http://ako-k.com/images/button_88x31.jpg

Offline

 

#3 2005-01-20 10:43 pm

iZach004
Member
From: Indianapolis, IN, 46240
Registered: 2001-06-04
Posts: 176
Website

Re: MySQL and line breaks

It's perfect! Thanks!

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson