Jump to content


Photo

Formatting text retrieved from mysql database?


  • Please log in to reply
2 replies to this topic

#1 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 19 August 2006 - 11:26 PM

I have the following form which allows admins on the site to add news topics. I can retrieve the text from the database and print it where it needs to go, but the problem lies in the formatting of the text for example if a user wanted text to be on 3 lines:

one
two
three

instead the result is one two three. I tried just simply using <pre> but this makes the text exceed the container i have placed it in.

Any suggestions?

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:45 PM

Sounds like you're in need of a line break or am I missing something here?

Erm, just thought - when echo'ing the text to the browser try this:
echo nl2br($variable);

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 19 August 2006 - 11:53 PM

Yea that works thank you very much for the help




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users