Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Text from MySQL DB

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello;

I have a question relative to content management. I am working on a website framework,using PHP and MySQL, that aims to allow non-developers to maintain sites based on it. My problem comes in delaing with content. I would like users to be able to enter the textual content for a page in a textarea, and insert that into the DB. All fine, as far as it goes.....however, when the actual content page fetches the text from the DB, I want it to be broken into paragraphs in the way that the user entered it.

I have been experimenting with PRE tags in an effort to force paragraph breaks, etc, with no luck. Does anyone know something about that? Thanks.
 
Use the nl2br() function when they enter their data into the database.

The function will convert all newlines (nl) to (2) br (<br>) tags.

[tt]
$text = nl2br($text);
[/tt]

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
 
Vic-

Thanks alot! You have saved me a ridiculous amount of time and frustration!!!
 
Is there a
Code:
br2nl();
function too? -gerrygerry
geraldschafer@hotmail.com
 
Why would you want a function to do that?

Anyway, if you did want to do that, you could use a regular expression.

Also, you can always check for the PHP manual and search it to see if the function exists.

-Vic
vic cherubini
krs-one@cnunited.com
 
Just a side thought. Wasn't really a focus, just saw this post and being the newby I am I said, &quot;hey gerrygerry, I wonder if you could do something like that to read a HTML file with breaks in it into a textarea for something?&quot;... then I moved on. Maybe some sort of a html-free page editor?LOL

Thanks for the link Vic. -gerrygerry
geraldschafer@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top