Retain formatting with <textarea>
Moderator: General Moderators
Retain formatting with <textarea>
I have a text area form object and whenever I save the contents onto mysql, none of the formatting is saved is there a way I van retain formatting like newlines and such without having to actually use html code within the post?
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
how would I integrate the nl2br() function within the <textarea> tag? I saw something about it as a post on the function reference page but I I really don't know if it was what I needed. the post was by of:
jhfh at hetnet dot nl
I also tried looking through the source of the thread posting page and found a js function called storeCaret(this);. is this important?
jhfh at hetnet dot nl
I also tried looking through the source of the thread posting page and found a js function called storeCaret(this);. is this important?
Use [php_man]wordwrap[/php_man].
Example (from the manual):
Example (from the manual):
Code: Select all
Wraps a string to a given number of characters using a string break character. (PHP 4 >= 4.0.2)
string wordwrap ( string str [, int width [, string break [, boolean cut]]] )
Returns a string with str wrapped at the column number specified by the optional width parameter. The line is broken using the (optional) break parameter.
wordwrap() will automatically wrap at column 75 and break using '\n' (newline) if width or break are not given.
If the cut is set to 1, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart. (See second example).
Note:
The optional cut parameter was added in PHP 4.0.3
Example 979. wordwrap() example
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />");
echo "$newtext\n";
?>
This example would display:
The quick brown fox
jumped over the
lazy dog.-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
so then
i have a personal comments / about me textarea on my site (longtext format in MySQL) now even though i have pressed return when filling out the form so in the text area is looks like this
i have a personal comments / about me textarea on my site (longtext format in MySQL) now even though i have pressed return when filling out the form so in the text area is looks like this
it does thisI am a web-designer
I am also learning PHP
should i create a replace string?[/quote]i am a web-designer i am also learning PHP
That's exactly my problem. I don't want to word wrap at a certain point or type in newlines everywhere, I want to retain what formatting was inputted into the textarea, so if I made a list like:
1.
2.
3.
It would come out exactly like that instead of:
1.2.3.
But I will remember the other functions in future problems needing them. thanks!
P.S.
Does anyone hava an exmple of this with source?
1.
2.
3.
It would come out exactly like that instead of:
1.2.3.
But I will remember the other functions in future problems needing them. thanks!
P.S.
Does anyone hava an exmple of this with source?
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK