This is a discussion on blank lines problem within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I have a strange problem using php and textarea input. When i have an textarea in a form like ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I have a strange problem using php and textarea input. When i have an textarea in a form like line 1 etc etc blank line line 3 etc etc line 4 etc etc blank line blank line line 7 Later I put the textarea in a mysql table. Reading back and display in an textarea. I see that the text is one line discarding the blank lines. How can I preserve the blank lines when storing in database and reading back in php. thanks Johan |
|
|||
|
Line feeds should be automatically preserved. What are you doing to the
input prior to the INSERT call? What are you doing to output after the SELECT call? What does the HTML source of the textarea look like when it is read from the database? -Robert |
|
|||
|
"rlee0001" <robeddielee@hotmail.com> schreef in bericht news:1143282965.440587.39440@i40g2000cwc.googlegro ups.com... > Line feeds should be automatically preserved. What are you doing to the > input prior to the INSERT call? What are you doing to output after the > SELECT call? What does the HTML source of the textarea look like when > it is read from the database? > > -Robert > $query = "select * from tbl_profile where id = $id";' $result = mysql_query($query); $row = mysql_fetch_assoc($result) $profile_oms = $row['profile_oms']; <textarea name="profiel_oms" rows="10" class="textfield" id="profiel_oms"> <?php print "$profile_oms"; ?> </textarea> Johan |
|
|||
|
Hmm,
There is nothing there to remove line feeds from the data. Are you sure the data was stored with line feeds intact? When you view the resulting HTML source is the content of the textarea all on one line or does it just render that way? If you really are getting a single line of text from that query, the data was stored without line feeds and you should check to INSERT (or UPDATE) procedures. It might also be possible that a CSS style is being applied to the textarea so that it ignores line feeds and renders its contents all on one line. Try sending $profile_oms to the contents of a PRE tag as well. Also, make sure you apply a htmlspecialchars to any output from a data source that is sent to an HTML document. -Robert |