Forum Moderators: coopster

Message Too Old, No Replies

formatting my output

         

Smad

11:38 am on Oct 7, 2004 (gmt 0)

10+ Year Member



hi all

Is there a simple way of auto enlosing clumps of text from a mysql database in paragraph tags?

TIA

hughie

12:24 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



very basically

echo '<p>'.$row[Output].'</p>';

not sure thats what you were after though.
ta,
hughie

lazydog

12:42 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



maybe you need the function nl2br?

Smad

1:03 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



hi thanks for replys

I was looking at the function that inserts breaks, what i think i will need to do is look for whitespace then replace it with a p tag.

basically i want it to work like this box, that is the way text is enter is the way it is then displayed on the page.

mincklerstraat

3:44 pm on Oct 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The way this is usually done is using nl2br.
"This box", the one I'm typing in and the one you were typing your message in, lets you type and:

there, I just did some carriage returns and lo and behold there are spaces! Thing is, these are returned from "this box" (which is a <textarea>) in the form of linebreaks - or rather, \n (and \r in macs, and \r\n in windows). HTML doesn't display line breaks this way, so you just do:
$html = nl2br($html);
and that converts the linebreaks that come in from the textarea to linebreaks as displayed in HTML.

[be2.php.net...]

Smad

4:10 pm on Oct 7, 2004 (gmt 0)

10+ Year Member



now i see. thank you for pointing me in the right direction