Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OKay I'm Rusty! Textarea questions

Status
Not open for further replies.

QuietFire

Programmer
Feb 25, 2003
12
US
So I've been out of programming for a year and when I was in it it was a different language!

My question is simple. I have a textarea on a form. I want to be able to store the linebreaks with the text in a text feild on a mySQL.

I have a distant memory about looping throught the text lines and looking for /n but it just isn't coming to me and Google is just laughing at my questions!

Thus I moning on to another segment of what I'm doing and hoping to find the answer here later.

Thank you so much for who ever points this obvious answer out to me!

Charlie
 
The textbox has a property like multiline set to true.

If you do an "echo;" for the text, it should appear as it is, with line breaks, etc...

To store it in a single textfield you have to transform the special charcters, like: /n, /t, /v ...

You will need a pair of functions. In javascript these are:
- escape(""); // convert the special chars
- unescape(""); // oppossing function

Try to find the equivalent to those functions in PHP. I can't help you any more; I don't know/work with PHP.
 
if your're trying to output data from a table with line breaks, consider using this built in php function:
Code:
nl2br($str);
Hope it helps!

Regards,

Martin

Computing Help And Info:
 
>>I want to be able to store the linebreaks with the text in a text feild on a mySQL.

it will save line breaks AS is, only when u show them back u may have to use nl2br();

Known is handfull, Unknown is worldfull
 
Thanks to All.

vbkris Concise complete answere! I figured out the line breaks saved in the table when I dropped the data back into a textarea for editing they were magicly there!

Another project or to like this and I'll no longer be a "rusty" programmer!

Charlie
 
no problemmo...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top