Re: textarea new line to mysql database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/5/15 PHPScriptor <contact@xxxxxxxxxxxxxxx>:
>
> Well, the problem is that I have a lot of forms, a lot of data to output, and
> even then, I don't know always where I have a textarea or just a inputfield.
> But true, I could even set the nl2br on an input field, it wouldn't make a
> difference.
> But I just don't understand why this problem exists? What's the reason?

Trust me when I say in the grand scheme of things a call to nl2br is
extremely cheap so I really wouldn't worry about how much you use it.

If you don't know whether you're using a input field or a textarea I
really think you need to examine your code carefully before
proceeding. If you know to spit out a textarea then you know it's a
textarea. Or maybe I'm missing something.

The reason this "problem" exists is due to HTML compressing concurrent
white space into a single space. This can be a very useful feature but
is not immediately obvious to newcomers. If you're not familiar with
HTML I suggest you put PHP down for a while and have a play with pure
HTML - it'll be time well-invested.

-Stuart

-- 
http://stut.net/

> Stuart-47 wrote:
>>
>> 2009/5/15 PHPScriptor <contact@xxxxxxxxxxxxxxx>:
>>>
>>> Hello,
>>>
>>> How do you guys handle this "problem".
>>>
>>> Just a form with a textarea. When I use enters in the textarea it's saved
>>> to
>>> the db like this:
>>>
>>> database:
>>> "first line
>>> second line"
>>>
>>> when I edit the value in the form:
>>> "first line
>>> second line"
>>>
>>> when I output the value to html:
>>> "first linesecond line" (unless I use nl2br())
>>>
>>> Is there a way that I could save it to the db that will work for db,
>>> output
>>> and edit without using any other function like nl2br?
>>
>> What's your problem with using nl2br? This is the reason it exists!!
>>
>> Store the raw data in the database, and run nl2br on it when you
>> display it. I don't see a "problem".
>>
>> -Stuart
>>
>> --
>> http://stut.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>
> -----
> visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/
> --
> View this message in context: http://www.nabble.com/textarea-new-line-to-mysql-database-tp23560478p23560853.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux