Re: Paragraph returns
| From: | Olivier Bourgeois | Date: | Fri, 22 Dec 2000 11:41:17 +0000 |
| Subject: | Re: Paragraph returns | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-5402@lists.php.net to get a copy of this message | ||
Toby Butzon wrote:
If I understand correctly, you're trying to make HTML output be formatted just as it was typed in the textarea box; therefore, we need to replace all line-breaks in the textarea box ("\n") with breaks or paragraph marks ("<br>" or "<p>", respectively). It's fairly simple; if your textbox were named "myText", you'd do this in your PHP (either before display or before insertion into the database, but make that decision based on if the data may be needed for other uses; if you're only going to display it on the web, it's probably best to go on and do the conversion): $myText = str_replace("\n", "<p>", $myText); Toby Butzon [ criticism spurs improvement ] You can also use PHP functions to do this :$myText = nl2br ($myText) ; nl2br replaces all \n with <br> : I know it's not <P> ;-) And if really want to update HTML in your site via a form, you should take care that some characters have a special value in HTML, like < or " . The double quotes could also confuse PHP for your query string. PHP have two other functions that converts these characters: $myText = HTMLSpecialChar ($myText); convertions done '&' (et commercial) devient '&' '"' (guillement double) devient '"' '<' (inférieur à) devient '<' '>' (supérieur à) devient '>' and $myText = HTMLEntities ($myText); that converts all special chars known in ISO-8859-1 bye
----- Original Message ----- From: "Lisa Rubanowicz" <info@navanwebdesign.com> To: <php-db@lists.php.net> Sent: Thursday, December 21, 2000 4:49 PM Subject: [PHP-DB] Paragraph returns : Hi All, : I hope you can help. I am a total beginner at PHP but am eager to learn. : I have two pages, very basic at the moment. : http://www.navanwebdesign.com/in.php which is a web form sending data to : a mySQL database. : On page two http://www.navanwebdesign.com/out.php is a listing of all : data entry from page 1. : Now supposing I wanted to use this so I can update my web site through a : web form I need to be able to do Paragraph returns <P> like so. : QUESTION: What do I type in the TEXTAREA box to result in a <P> in the : output (out.php) which comes from the database. Or do I have to check : the input in the TEXTAREA box for <P> and replace with something else in : the PHP code - If so how do I do this. : : I have tried several varieties of "\r\n" , in the TEXTAREA box, : but as I am a beginner I am lost now and it is SOOOO frustrating. : I would like to thank you for your help in this matter : Seasons greetings : all the Best : Lisa Rubanowicz : Ireland : : : -- : PHP Database Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net : For additional commands, e-mail: php-db-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : :