fun_g
asked on
How can I place a carriage return in text field from database?
I have setup a multi-line text field for entry to a database. Many users try separating items and tesk by hitting enter supplying them with a new line within the text field although when the data is queried and displayed in the page it does not show the carriage return that has been used for oganization.
I have seen this on Google calendar and I am trying to get that look. How is this done?
Thank you all,
gorg
I have seen this on Google calendar and I am trying to get that look. How is this done?
Thank you all,
gorg
ASKER
cxr,
Thank you very much for your quick response.
This function looks like it is more geared for line by line query from the database. I am submitting a text field and calling the text field to display the data on the page. Within the text field I need to preserve the carriage returns for display within the text box on the page.
Thank you,
gorg
Thank you very much for your quick response.
This function looks like it is more geared for line by line query from the database. I am submitting a text field and calling the text field to display the data on the page. Within the text field I need to preserve the carriage returns for display within the text box on the page.
Thank you,
gorg
Can you show your code?
>> for display within the text box
What kind of text box? A <textarea>? Or a paragraph <p> or <div>?
For a textarea, no conversion should be necessary. For a paragraph or div, use nl2br().
>> for display within the text box
What kind of text box? A <textarea>? Or a paragraph <p> or <div>?
For a textarea, no conversion should be necessary. For a paragraph or div, use nl2br().
ASKER
The entry in the form is a <textarea> but the code that I am calling it back with is listed below. How can I call it to a <textarea>. Lack of knowledge here. :(
$return .= "<td>";
$tmp = ($dietsheet->text_5) ? $dietsheet->text_5 : " ";
$return .= "<div id=\"tDSText5_$dietsheet->cf_id\">{$tmp}</div>";
$return .= "<input id=\"tbDSText5_$dietsheet->cf_id\" style=\"display: none; float: left; width: 70%\" type=\"text\" value=\"{$dietsheet->text_5}\">";
$return .= "</td>";
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Heh! I forgot, EE removes the from the code snippet. The " " at the end of the code snippet contained (nonbreakable space)
ASKER
cxr,
The addition 'n12br' worked perfect. Thank you very much. This has loaded the page with the correct format. Thank you for your time.
gorg
The addition 'n12br' worked perfect. Thank you very much. This has loaded the page with the correct format. Thank you for your time.
gorg
http://php.net/manual/en/function.nl2br.php
This function converts linefeeds to <br> tags, so that they break lines in html.