Jump to content


how to re-justify/format text from mysql

  • Please log in to reply
2 replies to this topic

#1 snowy190uk

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 March 2006 - 02:19 PM

Hi there,

I'm setting up really simple website for a youth orginisation where people can add ideas for games/crafts. I'm using mysql and php.

I've got it all working apart from when I do a query and display what someone has typed in. In PHPadmin the 'justification' is all there - spaces, extra 'returned' lines and paragraph end's. (like in this text). However when I query the mysql database and display an entry it all comes out totally unjustified - like its lost all of the returns etc...

Is there anyway of changing this? I'm starting to think its how the text is stored in the mysql database, or perhaps how its uploaded - but I don't know what to change to get it working!!

Any help would be great!


#2 ober

  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 23 March 2006 - 02:26 PM

You need to apply the nl2br() function to the output.

echo nl2br($row['stuff']); will display the results with all the "returns" and whatnot put in there like it was entered.

Justifying in terms of alignment is all done in your CSS/styling and has nothing to do with the mysql output.

Info: PHP Manual

#3 snowy190uk

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 23 March 2006 - 02:38 PM

aahhhh - pure relief!! Thanks for that - it's one area i've not covered before.

Many thanks once again,

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users