简体   繁体   中英

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. 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.

Any line breaks in the space between the <textarea></textarea> tags are displayed in the text box. If you replace "<br>" with "\\n" it should work.

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.

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

output look like:
abc
xyz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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