简体   繁体   English

在带有换行符的文本区域中显示新数据

[英]display new data in a text area with a line break

<textarea name="notes"rows="2" cols="70" readonly><?php if(!empty($this->log_note)){ echo $this->log_note;} ?>
</textarea><br><br> 
<label for="add_note"> Add Note </label>
<textarea name="add_note" rows="2" cols="70">
</textarea>                 

Lets say I have a text area in a form that displays data from a database table. 可以说我有一个文本区域,它的形式显示数据库表中的数据。

Now I have another text area field, and when I enter data it will update the above table field with the data entered. 现在,我有另一个文本区域字段,当我输入数据时,它将使用输入的数据更新上面的表格字段。

    $post_notes=$this->post['notes'];
    $post_add_note=$post_notes."<br>".$this->post['add_note'];

    $add_note_update=$this->db->query("
                     UPDATE notes SET note='$post_add_note' WHERE id='$hidden_id'
                 ");

Now next time when I display the text area field with the name 'notes', I want the data in the text area to be displayed in a newline. 现在,下一次当我显示名称为“ notes”的文本区域字段时,我希望文本区域中的数据以换行符显示。 ie My 即我的
tag should work or is there any other way to display it with a line break? 标签应该可以工作,或者是否有其他方式可以将其显示为带有换行符?

NOTE: I will take care of the SQL injection scenarios, but I want to get my logic right first. 注意:我将处理SQL注入方案,但是我想首先弄清楚我的逻辑。

Any line breaks in the space between the <textarea></textarea> tags are displayed in the text box. <textarea></textarea>标记之间的空格中的任何换行符都会显示在文本框中。 If you replace "<br>" with "\\n" it should work. 如果将"<br>"替换为"\\n"它应该可以工作。

Best way when u typing your data in textarea please add at the end of line "< br />" It will start printing next data in new line. 当您在textarea中键入数据时,最好的方法是在“ <br />”行的末尾添加。它将开始在新行中打印下一个数据。

eg: abc< br /> xyz< br /> 例如:abc <br /> xyz <br />

output look like: 输出如下:
abc abc
xyz y

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM