Re: html formatting in mysql post

From: Date: Sat, 07 May 2011 03:04:44 +0000
Subject: Re: html formatting in mysql post
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-312711@lists.php.net to get a copy of this message
On Fri, May 6, 2011 at 22:52, Ross Hansen <hansen.ross@live.com.au> wrote: > > Hey Guys, > > I am using a form to post information to a MySQL table which is then echo(ing) back out to a > web page. it will sort of be like facebook where you can post messages and stuff on peoples walls. > The only issue is at the moment i can get the formatting to stay. When i echo the table out from > mysql it all gets displayed on one line rather than seeing my new lines which i typed in the text > box. > I do know that this is a HTML error as it was never given the format tags when the content was > posted in the table. > > I have seen something about NL2BR and also something about strip slashes but i am not sure how > to incorporate them into my post. > > Could someone please advise? Well, let's start with an easy question: have you *tried* them? <?php // $row = /* Database row grabbed elsewhere in your code. */''; if (is_array($row)) { foreach ($row as $r) { echo nl2br($row).PHP_EOL; } } else { echo nl2br($row).PHP_EOL; } ?> Error-handling and the remainder of checking is up to you. -- </Daniel P. Brown> Network Infrastructure Manager http://www.php.net/

« previous php.general (#312711) next »