Re: Formatting a form box
| From: | Bastien Koert | Date: | Thu, 12 Jan 2006 21:35:48 +0000 |
| Subject: | Re: Formatting a form box | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41030@lists.php.net to get a copy of this message | ||
show the code bit relevant to the nl2br issue and conversion
bastien
From: Alex Major <alex.major@allydm.co.uk> To: <tg-php@gryffyndevelopment.com>,<php-db@lists.php.net> Subject: Re: [PHP-DB] Formatting a form box Date: Thu, 12 Jan 2006 19:42:33 +0000 Thanks for the suggestions, the nl2br has been a common suggestion and think that I have found more of what the problem is. (And it is kinda php specific cause its php pages). Basically its not displaying it correctly on the page, the text in the database is now being stored correctly (with lines / breaks where they are supposed to be) but for some reason when that info is then pulled from the database, the lines get removed. Any ideas why? On 12/1/06 17:41, "tg-php@gryffyndevelopment.com" <tg-php@gryffyndevelopment.com> wrote: What? Nobody said "This has nothing to do with PHP and databases?" Sheesh... someone must be sleeping. :) Ok, so it sorta does relate.. But yeah... no2br() will do it for you. Textarea input types DO send a newline and/or carriage return (didn't test and might be system specific), so if you just take your form $_POST data and use nl2br() before you store it in the database (or probably after... should be able to store a newline/carriage return in the database) it should produce the results you desire. test.php: <form action="test.php" method="post"> <textarea name="testarea"> </textarea> <input type="submit"> </form> <?php if (isset($_POST['testarea'])) { echo nl2br($_POST['testarea']); } ?> Look at the source code after you submit if you have any doubts/questions. -TG = = = Original message = = = use the nl2br() function to convert the newlines to <br> bastienetc..andFrom: Alex Major <alex.major@allydm.co.uk> To: <php-db@lists.php.net> Subject: [PHP-DB] Formatting a form box Date: Thu, 12 Jan 2006 16:33:01 +0000 Hi there, On one of my forms, there is a section where users can put imagessothen it is displayed on my php pages. My question is how do I make itsomeone isthat the html formatting is automatically done. For example whenpresstyping something, and wants to start a new paragraph although theyon areturn when typing when the data is displayed from the MySQL databasethewebsite it's just continuous text. For it to start a new paragraph they have to put <p> in when they are typing in this box. They do not know alleasyhtml formatting codes, and so I need someway of making so that it isgood.for them to have formatted text without doing all the html. Also things like changing colours, bold, italic and things would betheSomething like on forums, where when you enter a new post you have all___________________________________________________________ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpformatting options. Hope this makes sense, Regards, Alex.