Results 1 to 4 of 4
-
31st Aug 2011, 09:12 AM #1OPBanned
Problems showing a newline within a textarea, once grabbed info from within a db
Basically i am having a little problem displaying a newline within a textarea. The contents of the text area are grabbed from a database, which have already previously converted all newlines to <br> tags, as i would like to use it within a html page. But i also want to offer a user the chance to edit this data via the use of a textarea. Now the problem is i would like the textarea to display the content in the same way it does on a html document, So i decided to replace <br> with \n once again, and then post the content within the <textarea>...</textarea> tags. But I seem to be getting "content with a \n instead of actually showing the newline itself". How would i overcome this??
utomtear Reviewed by utomtear on . Problems showing a newline within a textarea, once grabbed info from within a db Basically i am having a little problem displaying a newline within a textarea. The contents of the text area are grabbed from a database, which have already previously converted all newlines to <br> tags, as i would like to use it within a html page. But i also want to offer a user the chance to edit this data via the use of a textarea. Now the problem is i would like the textarea to display the content in the same way it does on a html document, So i decided to replace <br> with \n once Rating: 5
-
1st Sep 2011, 02:41 PM #2Member
it's php, right?
maybe you have to change 'single quotes' to "double quotes" around that \n?
-
1st Sep 2011, 02:42 PM #3The Wise OneWebsite's:
twilight.ws ddlrank.comUse php's nl2br function: http://php.net/manual/en/function.nl2br.php
-
1st Sep 2011, 02:47 PM #4MemberWebsite's:
epicimagehost.comAs deliteblogger said, be sure to use double quotes for your newline.
PHP Code:<?php
$newline = "\n";
$text = 'Hello world';
echo '<textarea>';
echo $text . $newline; // -> Hello world + newline
echo $text . "\n"; // -> Hello world + newline
echo 'Hello World' . "\n"; // -> Hello world + newline
echo '</textarea>';
?>
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Installed WP is not showing !
By shufol in forum WordpressReplies: 7Last Post: 12th Nov 2012, 03:18 PM -
[Selling] creepy-video.info,online-stalker.info,scary-vid.info
By Porsche_maniak in forum Completed TransactionsReplies: 0Last Post: 12th May 2012, 08:46 AM -
[Selling] TwitterMoney.info, TopBetting.info, Watch-Shows.info (domains)
By min123 in forum Completed TransactionsReplies: 0Last Post: 3rd Jun 2011, 07:05 PM -
[Selling] TwitterMoney.info, TopBetting.info, Watch-Shows.info (domains)
By min123 in forum Completed TransactionsReplies: 1Last Post: 29th May 2011, 12:52 PM -
[Selling] TwitterMoney.info, TopBetting.info, Watch-Shows.info (domains)
By min123 in forum Completed TransactionsReplies: 5Last Post: 26th May 2011, 02:18 PM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...